Skip to content

Instantly share code, notes, and snippets.

@conschneider
Created May 28, 2020 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save conschneider/548c316888ac6684042ba40b33fd299b to your computer and use it in GitHub Desktop.
Save conschneider/548c316888ac6684042ba40b33fd299b to your computer and use it in GitHub Desktop.
Sets the URL to app_url so that OneSignal WordPress Push Notifications open the app instead of phone browser. Disables Browser Notifications.
<?php
/*
Plugin Name: WP OneSignal Push To App
Description: Sets the URL to app_url so that OneSignal WordPress Push Notifications open the app instead of phone browser. Disables Browser Notifications.
Version: 1.0
Author: Con & Anna Schneider
Author URI: https://conschneider.de
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
add_filter('onesignal_send_notification', 'onesignal_send_notication_filter_push', 10, 4);
function onesignal_send_notication_filter_push($fields, $new_status, $old_status, $post)
{
$fields['isAndroid'] = true;
$fields['isIos'] = true;
$fields['isAnyWeb'] = false;
$fields['isChrome'] = false;
$fields['url'] = $fields['app_url'];
return $fields;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment