打开时在 OneSignal 推送通知中禁用 Launch URL
Disable Launch URL in OneSignal Push Notification when opened
打开时无法在 OneSignal 推送通知中禁用启动 url。尝试将 kOSSettingsKeyInAppLaunchURL 从 true 切换为 false,它仍然打开 Safari。
如何才能完全删除启动 Url?提前致谢。
我在 OneSignal app.component.ts 中的代码如下,
if (this.appConfig.Onesignal_Enable == true) {
this.oneSignal.startInit(this.appConfig.OneSignal_AppID, this.appConfig.GCM_SenderID);
this.oneSignal.iOSSettings({
kOSSettingsKeyInAppLaunchURL: false,
kOSSettingsKeyAutoPrompt: true,
});
this.oneSignal.handleNotificationOpened().subscribe(() => {
// do something when a notification is opened
this.navCtrl.navigateForward('positions');
});
this.oneSignal.endInit();
}
在网络端解决了它,而不是 PHP。对于使用 WordPress 运行 的任何人来说,这是一个很棒的过滤器。
add_filter( 'onesignal_send_notification', 'onesignal_send_notification_filter', 10, 4 );
function onesignal_send_notification_filter($fields, $new_status, $old_status, $post) {
// Set player ids as subscribed to onesignal notification (see users in onesignal dashboard)
$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;
}
您可以将 launchURL 的架构更改为不是 http
或 https
的内容
打开时无法在 OneSignal 推送通知中禁用启动 url。尝试将 kOSSettingsKeyInAppLaunchURL 从 true 切换为 false,它仍然打开 Safari。
如何才能完全删除启动 Url?提前致谢。
我在 OneSignal app.component.ts 中的代码如下,
if (this.appConfig.Onesignal_Enable == true) {
this.oneSignal.startInit(this.appConfig.OneSignal_AppID, this.appConfig.GCM_SenderID);
this.oneSignal.iOSSettings({
kOSSettingsKeyInAppLaunchURL: false,
kOSSettingsKeyAutoPrompt: true,
});
this.oneSignal.handleNotificationOpened().subscribe(() => {
// do something when a notification is opened
this.navCtrl.navigateForward('positions');
});
this.oneSignal.endInit();
}
在网络端解决了它,而不是 PHP。对于使用 WordPress 运行 的任何人来说,这是一个很棒的过滤器。
add_filter( 'onesignal_send_notification', 'onesignal_send_notification_filter', 10, 4 );
function onesignal_send_notification_filter($fields, $new_status, $old_status, $post) {
// Set player ids as subscribed to onesignal notification (see users in onesignal dashboard)
$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;
}
您可以将 launchURL 的架构更改为不是 http
或 https