-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onOpened event not triggered when app runs in background. #581
Comments
Have you seen this issue regarding RN app restarts? #583 |
This issue should now be fixed in version 3.2.6 |
Hello, I'm having the same problem. When the app is in the background and I open the notification it takes me to the app but it doesn't trigger the events, and when the app is opened or not opened at all it works fine. Here are the versions I'm woking with: I'm also running it on an android device, android version 9. I haven't been able to test it on an iPhone yet. |
add OneSignal.inFocusDisplaying(2); |
I am using one signal version "react-native-onesignal": "^3.5.0" |
Still not working, any updates? |
Description:
Hi guys this is my first call for help. I have an issue getting the onOpened event to fire when a notification is clicked on when the app is running in the background. It works perfectly from a cold start meaning when the app is completely closed and opened by pressing on the notification. onReceived, Init and everything else works fine. Followed the setup docs as is. Ive been reading everywhere and looked at the example project.
Environment
"react": "16.3.1",
"react-native": "0.55.4",
"react-native-onesignal": "^3.2.5"
Added using Yarn
compileSdkVersion 23
buildToolsVersion "27.0.3"
Running on Android device
Steps to Reproduce Issue:
`
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
AppState,
Text,
Alert,
View
} from 'react-native';
import { Root } from "native-base";
import { Router, Scene, Actions } from 'react-native-router-flux';
import OneSignal from 'react-native-onesignal';
import stores from './app/libs/mrDataLib';
import { observer, Provider, inject } from 'mobx-react/native'
import onBoarding from './app/pages/onBoarding/mrOnBoarding';
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
};
}
componentWillMount() {
OneSignal.init("xxxxxxxx-xxxxxxx-xxxxxxxx-xxxxxxx");
OneSignal.configure();
OneSignal.inFocusDisplaying(2);
}
componentDidMount() {
this.onOpened = this.onOpened.bind(this); // Taken from onesignal example
OneSignal.addEventListener('opened', this.onOpened);
OneSignal.addEventListener('received', this.onReceived);
}
componentWillUnmount() {
OneSignal.removeEventListener('received', this.onReceived);
OneSignal.removeEventListener('opened', this.onOpened);
}
onOpened(openResult) {
// This is where my problem lies
// Fires when app is not running and opened from notification clicked.
// Does not fire when app is running in the background or minimised.
Alert.alert('Test');
};
onReceived(notification) {
Alert.alert('Test');
}
render() {
return (
<Root>
<Provider store={stores}>
<Router wrapBy={observer}>
<Scene key="root">
<Scene hideNavBar={true} key="onBoarding" back={false} component={onBoarding} title="onBoarding" initial={true} />
</Scene>
</Router>
</Provider>
</Root>
);
}
Anything else:
I have looked online but with no luck, please can you help me.
The text was updated successfully, but these errors were encountered: