uni-app中globalEvent事件无法使用
uni-app中globalEvent事件无法使用
操作步骤:
- uni app无法收到消息
预期结果:
- uni app可以收到消息
实际结果:
- uni app无法收到消息
bug描述:
安卓中使用发送:
Map<String,Object> params=new HashMap<>();
params.put("title", remoteMessage.getNotification().getTitle());
params.put("body", remoteMessage.getNotification().getBody());
WXSDKInstance wxsdkInstance = new WXSDKInstance();
wxsdkInstance.fireGlobalEventCallback("fcmNotify", params);
uni中获取:
plus.globalEvent.addEventListener('fcmNotify', function(e){
uni.showModal({
title:'fcm notify',
content:"fcmNotify收到:"+JSON.stringify(e)
});
});
更多关于uni-app中globalEvent事件无法使用的实战教程也可以访问 https://www.itying.com/category-93-b0.html
List<WXSDKInstance> instances = WXSDKManager.getInstance().getWXRenderManager().getAllInstances();
for (WXSDKInstance instance : instances) {
instance.fireGlobalEventCallback(eventName, result);
}
更多关于uni-app中globalEvent事件无法使用的实战教程也可以访问 https://www.itying.com/category-93-b0.html
还是这个最靠谱
我现在遇到问题是第一次安装的时候安卓代码已经触发回调了,但是在 vue 获取不到,杀死 app 后再次打开就可以获取到了
List instances = WXSDKManager.getInstance().getWXRenderManager().getAllInstances(); for (WXSDKInstance instance : instances) { instance.fireGlobalEventCallback(eventName, result); } 正常这个是可以的,因为这个是发送到所有页面的
搞定了,安卓端发送前循环获取WXSDKInstance实例,获取到后不要立即发送,要等几秒后再发送


