简体   繁体   English

OneSignal 未在多个设备上注册 - React Native

[英]OneSignal not registering on multiple devices - React Native

Currently I have managed to setup OneSignal properly on Android and iOS.目前我已经设法在 Android 和 iOS 上正确设置 OneSignal。 The problem I am encountering however, is that the only devices that are subscribed and showing up in my OneSignal dashboard are the two initial devices.然而,我遇到的问题是,在我的 OneSignal 仪表板中订阅和显示的唯一设备是两个初始设备。 (One which is an emulated Pixel 3 XL and the other which is a real iPhone X) These two devices were setup following the OneSignal React Native documentation herehttps://documentation.onesignal.com/docs/react-native-sdk-setup (一个是模拟的 Pixel 3 XL,另一个是真正的 iPhone X)这两个设备是按照此处的 OneSignal React Native 文档https://documentation.onesignal.com/docs/react-native-sdk-setup设置的

From my understanding, OneSignal automatically subscribes new devices to the dashboard with the OneSignal.init() method or OneSignal.setAppId() method for my case.据我了解,OneSignal 使用 OneSignal.init() 方法或 OneSignal.setAppId() 方法自动将新设备订阅到仪表板。 I am not too sure if I have to have some additional code to support this.我不太确定是否必须有一些额外的代码来支持这一点。

Here is my entry file that works for the 2 initial devices.这是适用于 2 个初始设备的我的条目文件。

index.js (changed app id to the default, to hide my actual one) index.js(将应用 ID 更改为默认值,以隐藏我的实际 ID)

React.useEffect(() => {
    OneSignal.setAppId('ce8572ae-ff57-4e77-a265-5c91f00ecc4c');
    OneSignal.setLogLevel(6, 0);
    OneSignal.promptForPushNotificationsWithUserResponse(response => {
      console.log(response);
    });
  }, []);

Thanks for any help!谢谢你的帮助!

This issue has been resolved.此问题已得到解决。 Turns out my code was not being run in my index.js file so moving it to App.js fixed it for me.原来我的代码没有在我的 index.js 文件中运行,所以将它移动到 App.js 为我修复了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM