Push Notification
This section guide to config the app to work with OneSignal app
You need to setup OneSignal account to support push notification (https://onesignal.com)
Install OneSignal Wordpress plugin to support push notification after publish a post:
iOS Config
Login to Onesignal, create a new app, go to app setting Config the Apple IOS

Click Config to open the popup config, follow the guide Generate ios push Certificate to generate the certificate and upload to the site.

Select Tab "Keys & Id" to get the OneSignal app id, and open MStore project, common/config.js file and change the AppId:
OneSignal: {
appId: '85cbc2b5-4e0d-4214-9653-8054d06f4256'
},
Android config
Follow the same guide above for iOS

Select Tab "Keys & Id" to get the OneSignal app id, and open MStore project, common/config.js file and change the AppId:
OneSignal: {
appId: '85cbc2b5-4e0d-4214-9653-8054d06f4256'
},
Install Wordpress plugin
Go to Configuration and fill in the APP ID, REST API Key, and your subdomain.

The default setting for the plugin "Automatically send a push notification when I create a post from the WordPress editor" is turn on, it's mean whenever you publish the post item, it will send notification auto to your user mobiles.
function onesignal_send_notification_filter($fields, $new_status, $old_status, $post)
{
$fields['isAndroid'] = true;
$fields['isIos'] = true;
$fields['isAnyWeb'] = false;
$fields['isChrome'] = false;
$fields['data'] = array(
"id" => $post->ID,
);
/* Unset the URL to prevent opening the browser when the notification is clicked */
unset($fields['url']);
return $fields;
}
add_filter('onesignal_send_notification', 'onesignal_send_notification_filter', 10, 4);
Last updated