I have an ionic android app connected to OneSignal, and WordPress with which 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 the mobile app and not to the browser. However, when I click the notification it takes me to the web instead of the app.
The below code is for sending notification only to mobile app. When I use this code I get notification but it takes me to web. The code is pasted below from their documentation.
<?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;
}
try this.