0

I am trying to integrate react-native-moengage based push notifications to my React Native app and it is showing me Push Token Not Generated error.

Here is my code, where I am initialising the 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);
  }
}

I am trying to implement it just for android for the time being, so I need help with just that here. Please help if someone has figured out a way.

  • Can you please share the exact error log printed by the MoEngage SDK Side Note: MoEHelper.getInstance(getApplicationContext()).autoIntegrate(this); can be removed. This is a deprecated method and not required anymore. PS: I am member of the MoEngage's SDK team – Umang Oct 27 '18 at 18:52
  • @UmangChamaria **Push Token Not Generated** this is the exact error I am seeing while I am doing the Integration Validation provided on the dashboard. I have gone through the documentation but couldn't find anything. Thanks for the side note, I found this in the docs though. – Pulkit Gupta Oct 27 '18 at 19:05
  • Request you to shake the logs printed by the MoEngage SDK in the Logcat, that will help us identify the issue. You can share the logs with us at support@moengage.com. Regarding the deprecated API, it is present in the documentation for legacy SDKs if a note pointing legacy is missing will get it added. Thanks for pointing out. – Umang Oct 27 '18 at 19:11
  • I am having trouble with the notifications only in the production build, and there we don't have logs, in react-native atleast – Pulkit Gupta Oct 27 '18 at 19:14
  • You can enable logs from MoEngage SDK in production builds as well. Please refer to this link - https://docs.moengage.com/docs/troubleshooting-1#section--q-how-to-enable-moengage-sdk-s-debug-logs-for-signed-builds- Debugging this would require checking detailed logs and we might require some more inputs from your end. Lets keep the conversation going on the above shared email id. Thanks – Umang Oct 27 '18 at 19:31

1 Answers1

0

Are you using Android Emulator? You have to use "Google APIs" images to work with push notifications. Have a look Android emulator not receiving push notifications

Pavel Biryukov
  • 1,076
  • 12
  • 19