Hi. I've issue to get notification in background or foreground, i've followed any guide include the sample guide. I've successfully registering and get push token and then I create testing device with that. Here is my code:
// index.js
/**
* @format
*/
import { AppRegistry, DeviceEventEmitter } from 'react-native';
import App from './App';
import { name as appName } from './app.json';
import Pushwoosh from 'pushwoosh-react-native-plugin';
import PushwooshGeozones from 'pushwoosh-geozones-react-native-plugin';
import Config from 'react-native-config';
// this event is fired when the push is received in the app
DeviceEventEmitter.addListener('pushReceived', (e: Event) => {
console.warn('pushReceived: ' + JSON.stringify(e));
});
DeviceEventEmitter.addListener('pushOpened', (e: Event) => {
console.warn('pushOpened: ' + JSON.stringify(e));
alert(JSON.stringify(e));
});
// Alternative way
// const pushwooshEmitter = new NativeEventEmitter(NativeModules.Pushwoosh);
// pushwooshEmitter.addListener('pushOpened', (e: Event) => {
// console.warn("pushOpened: " + JSON.stringify(e));
// alert(JSON.stringify(e));
// });
Pushwoosh.init(
{
pw_appid: Config.PW_APP_ID,
project_number: Config.PW_PROJECT_NUMBER,
},
() => {
console.warn('pushwoosh success initiating');
},
() => console.warn('pushwoosh fail initiaing'),
);
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);
});
// Pushwoosh.setMultiNotificationMode(true);
AppRegistry.registerComponent(appName, () => App);
Solved. Idk how 😭
maybe becauseflavorDimension, the other same app with different app id is installed in my device.
Any suggestion to make it work although I install the other app too ?
Hi. I've issue to get notification in background or foreground, i've followed any guide include the sample guide. I've successfully registering and get push token and then I create testing device with that. Here is my code: