Last active
June 17, 2018 20:19
-
-
Save scottopolis/c8f960ca362b3e0f6e5f to your computer and use it in GitHub Desktop.
Send AppPresser Push Notification only to certain devices
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
/* | |
* Send notifications only to certain devices | |
*/ | |
// Change this hook | |
add_action( 'save_post', 'push_to_devices' ); | |
function push_to_devices() { | |
// this should be an array of user IDs that you want to send the pushes too. AppPresser saves device IDs if the app user is a logged in member of your WordPress site, for example in BuddyPress. This will not work unless the user has logged in through your app. | |
$recipients = array( 1, 24 ); | |
$message = 'Hi there!'; | |
$push = new AppPresser_Notifications_Update; | |
$devices = $push->get_devices_by_user_id( $recipients ); | |
if( $devices ) { | |
$push->notification_send( 'now', $message, 1, $devices ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment