How to make onesignal plugin send notification only to mobile app?


I have ionic android app connected to onesignal, and wordpress that i make posts through my wordpress site. I installed the onesignal plugin and put the customised code provided by onesignal to send notification only to mobile app and not to browser but still when i click the notification takes me to web instead of app see bellow code

Bellow code is for sendind notification only to mobile app. When i use this code i get notification but takes me to web instead of app

&amp:lt:?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 =&amp:gt: $fields[ url ]
):
/* Unset the URL to prevent opening the browser when the notification is clicked */
unset($fields[ url ]):
return $fields:
}

Bellow code is for sending both notifications to app and to web browser. When i use this code it works well i get browser notification and app notification. and when i click app notification it takes me to the app. But the issue is i only need notification to mobile app i dont need both which the above code could do it, but it does not

documentation.onesignal.com/docs/wordpress#section-opening-web-and-mobile-notifications-in-the-browser-and-app

As far as I understand, you want tapping on a url to open your app, as opposed to whatever your phone’s browser is. This is called &quot:deep linking&quot: and pretty much unrelated to how the notification was created (i.e. onesignal).

You basically have to set this up in your ionic app.
Here’s a blog entry I found about it: http://blog.ionic.io/deeplinking-in-ioni…

Leave a Reply

Your email address will not be published. Required fields are marked *