The code in the official document is a bit problematic. You can call the plus code with the following delay and wait for plus to load.
In addition, add the conditional compilation, only the code below the app will compile
// #ifdef APP-PLUS // trigger when the page loads setTimeout(function(){ if (plus){ var pinf = plus.push.getClientInfo(); var cid = pinf.clientid; // Client ID console.log (cid); // Monitor system notification bar message click event plus.push.addEventListener( ' click ' , function(msg){ // Business logic code for processing click messages }, false); // Monitor and receive transparent message events plus.push.addEventListener( ' receive ' , function(msg){ // Business logic code for processing transparent messages var options = {cover: false }; plus.push.createMessage(msg, " RemoteMSG " ,options); }, false ); } }, 4000 ); // #endif
client_id can be obtained
Read More:
- How to Solve jQuery error: Uncaught ReferenceError: $ is not defined
- The browser is compatible with IE11 “ReferenceError: ‘Promise’ is not defined” “ReferenceError: ‘Promise’ is not defined”
- [Solved] Uncaught ReferenceError: FileAsyncWriter is not defined
- cloud.callFunction:fail Error:wx is not defined [How to Solve]
- [Solved] Eval Error: Uncaught ReferenceError: False is not defined
- [Solved] Electron Error: ReferenceError: require is not defined
- errorThrown:ReferenceError: data is not defined [How to Solve]
- R Language Error: variable does not have limits defined by datadist
- [Solved] Parcel Service Error: regeneratorRuntime is not defined
- [Solved] Vue Error: Failed to mount component: template or render function not defined
- <script setup> Error: ‘defineProps‘ is not defined [How to Solve]
- VUE: Property or method “deleteFun“ is not defined on the instance but referenced during render. [How to Fix]
- [Solved] Uncaught ReferenceError: is not defined at HTMLAnchorElement.onclick
- C++ new types may not be defined in a return type Error?
- Vue Import Baidu map error: BMap is not defined, eslint BMap reports an error
- [Solved] emcc error: error: LLVM_ROOT is not defined
- [HTTP] Solve the 406 not acceptable error
- How to Solve Error: Module did not self-register
- How to Solve Error: “initializer element is not constant”
- Burpsuite Error: ErrorsNo payload positions defined.