How to open push notifications in app instead of browser?
-
Hi everyone,
This questions has been asked by someone but not really solved.
I have created a native Android app with the content of the mobile version of the website bistro-proseven.de using Cordova. The app is working fine on my device and receiving push notifications via OneSignal.
My problem is that when I post a new blogpost and the app receives a push notification, when I click the notification the browser opens the post. But I want the app to open the post.
I found out that I have to unset the URL parameter and add a new key. So I pasted this code on my websites header file:
<?php function onesignal_send_notification_filter($fields, $new_status, $old_status, $post) { $fields['isAndroid'] = true; $fields['isIos'] = true; $fields['isAnyWeb'] = false; $fields['isChrome'] = false; $fields['data'] = array( "myappurl" => $fields['url'] ); /* Unset the URL to prevent opening the browser when the notification is clicked */ unset($fields['url']); return $fields; }
This code is from OneSignal Team and has been posted somewhere else when someone had a similar problem. So what the code does is saying that URL will be unset and myappurl will be the new additional data key.
My quesion is: How can I tell my app now to read the myappurl key and open the blogpost in my app instead of opening in the browser?
Thank you in advance!
The page I need help with: [log in to see the link]
- The topic ‘How to open push notifications in app instead of browser?’ is closed to new replies.