Created
May 28, 2020 20:06
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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