Skip to content

Instantly share code, notes, and snippets.

@stillatmylinux
Created April 10, 2019 17:16
Show Gist options
  • Save stillatmylinux/f28bf79f2989303156fc19162fa91b9f to your computer and use it in GitHub Desktop.
Save stillatmylinux/f28bf79f2989303156fc19162fa91b9f to your computer and use it in GitHub Desktop.
<?php
/**
* Overwrites the push notification title only for iOS for the AppPush plugin when sending
* push notification for a regular post.
*
* Place this file in the wp-content/mu-plugins folder.
* The mu-plugins folder is not there by default, you may have to create it.
*/
function custom_push__ios( $data ) {
global $post;
if( ! isset( $post ) ) {
return $data;
}
if( !isset( $data['custom'] ) ) {
$data['custom'] = array();
}
/**
* Sample:
*
* Overwrite the title and message for iOS only.
*
*/
$data['custom']['ios'] = array(
// When the app is open, the title of the alert pop-up
'title' => 'the alert message',
// When the app is closed, the text in the notification tray
// and when the app is open, the text of the alert pop-up
'alert' => $post->post_title,
);
return $data;
}
add_filter( 'ap3_send_push_data', 'custom_push__ios', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment