我正在尝试将基于 react-native-moengage 的推送通知集成到我的 React Native 应用程序中,它向我显示Push Token Not Generated错误。
这是我的代码,我在其中初始化 SDK:
public class MainApplication extends Application implements ReactApplication, PushManager.OnTokenReceivedListener {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new MoEReactPackage(),
new SplashScreenReactPackage()
);
}
@Override
protected String getJSMainModuleName() {
return "index";
}};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
MoEHelper.getInstance(getApplicationContext()).setExistingUser(false);
MoEHelper.getInstance(getApplicationContext()).autoIntegrate(this);
PushManager.getInstance().setTokenObserver(this);
MoEngage moEngage =
new MoEngage.Builder(this, "XXX")
.setSenderId("XXX")
.setLogLevel(Logger.VERBOSE)
.build();
MoEngage.initialise(moEngage);
SoLoader.init(this, /* native exopackage */ false);
}
@Override
public void onTokenReceived(String token) {
Toast.makeText(this, token, Toast.LENGTH_LONG);
}
}
我暂时只为android实现它,所以我在这里需要帮助。如果有人想出办法,请提供帮助。