Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29599

React-native Pushwoosh plugin not getting push notifications (Android)

$
0
0

I've followed this guide (https://docs.pushwoosh.com/platform-docs/pushwoosh-sdk/cross-platform-frameworks/react-native/integrating-react-native-plugin) on the website but it just isn't working in my project.

When I use the same init credentials in the example on GitHub, I get the notification.

My error is No task registered for key RNFirebaseBackgroundMessage

I followed the example to the letter so not really sure whats going on. Ive seen some things online about the error but none seem to help.

Here is my index.js file:

import App from './src/routes/routes';
import { name as appName } from './app.json';
import { setJSExceptionHandler, setNativeExceptionHandler } from 'react-native-exception-handler';
import firebase from 'react-native-firebase';

const reporter = (error) => {
    // Logic for reporting to devs
    // Example : Log issues to github issues using github apis.
    console.log(error); // sample
    firebase.crashlytics().log(error);
};

const errorHandler = (e, isFatal) => {
    if (isFatal) {
        reporter(e);
        Alert.alert(
            'Unexpected error occurred',
            `Error: ${(isFatal) ? 'Fatal:' : ''} ${e.name} ${e.message}
            We have reported this to our team ! Please close the app and start again!
            `,
            [{
                text: 'Close',
                onPress: () => {
                    BackHandler.exitApp();
                }
            }]
        );
    } else {
        firebase.crashlytics().log(e);
        console.log(e); // So that we can see it in the ADB logs in case of Android if needed
    }
};

setJSExceptionHandler(errorHandler);
setNativeExceptionHandler(exceptionString => { });

import Pushwoosh from 'pushwoosh-react-native-plugin';

AppRegistry.registerComponent(appName, () => App);

DeviceEventEmitter.addListener('pushOpened', (e) => {
    console.warn("pushOpened: " + JSON.stringify(e));
    alert(JSON.stringify(e));
  });

DeviceEventEmitter.addListener('pushReceived', (e) => {
console.warn("pushReceived: " + JSON.stringify(e));
// shows a push is received. Implement passive reaction to a push, such as UI update or data download.
});


  Pushwoosh.init({ "pw_appid" : "MY ID", "project_number":"MY NUMBER"});

  Pushwoosh.register(
    (token) => {
      console.warn("Registered for pushes: " + token);
      Pushwoosh.getPushToken(function(token) {
          console.warn("Push token: " + token);

          // Geolocation tracking example
          //PushwooshGeozones.startLocationTracking();
          //PushwooshGeozones.stopLocationTracking();
      });
    },
    (error) => {
      console.warn("Failed to register: " + error);
    }
  );

  Pushwoosh.getHwid((hwid) => {
    console.warn("Pushwoosh hwid: " + hwid);
  });```

Viewing all articles
Browse latest Browse all 29599

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>