Please help me for this case. I implement feature - push notification by OneSignal.
My situation as belows:
Android devices:
- Receive notification:
- App close: open push, navigate to specific Page I set. OK
- App open, run in background: open push, navigate to specific Page I set. OK
IOS devices:
- Receive notification:
- App close: open push, only open app, not go to specific page. NOT GOOD
- App open, run in background: open push, navigate to specific Page I set. OK
My snippet code:
HomePage.dart
void initState() {
_bloc = getCurrentBloc<HomeBloc>();
OneSignalWapper.handleClickNotification(context);
// OneSignalWapper.handleReceiveNotification(context);
super.initState();
}
OneSignalWapper.dart
static void handleClickNotification(BuildContext context) {
OneSignal.shared
.setNotificationOpenedHandler((OSNotificationOpenedResult result) async {
try {
var postId = await result.notification.payload.additionalData["post_id"];
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => PostDetailsScreen.newInstance('$postId')));
} catch (e, stacktrace) {
log(e);
}
});
}
Most of test cases are worked already. There is only one case: IOS, close APP (NOT GOOD case above).
How can I fix it. Please give some advices.
Thanks a lot!!!