1. [ ] You need to setup OneSignal account to support pushnotification (https://onesignal.com
  2. [ ] Install Wordpress plugin to support push notification after publish a post: https://vi.wordpress.org/plugins/onesignal-free-web-push-notifications/

  3. [ ] IOs Config:

Login to Onesignal, create a new app, go to app setting Config the Apple IOS:

  • Click Confige to open the popup config, follow the guide "https://documentation.onesignal.com/docs/generate-an-ios-push-certificate" to generate the certificate and upload to the site.
    + Select Tab "Keys & Id" to get the OneSignal app id, and open BeoNews project, go to ios/beoNews/AppDelegate.m and replace the App Id by your One Signal App Id:
    self.oneSignal = [[RCTOneSignal alloc] initWithLaunchOptions:launchOptions appId:@YOUR-APP-ID"];
  1. [ ] Android config:

    • Follow the same way with iOS
      + Select Tab "Keys & Id" to get the OneSignal app id, Go to android/app/build.grade and change the APP_ID & GOOGLE PROJECT NUMBER:
      manifestPlaceholders = [onesignal_appid: "APP_ID", onesignal_google_projectnumber: "PROJECT_NUMBER"]
  2. [ ] NOTE: The download package has already configure all the setting for you, but you need to replace the APP_ID to integrate with your OneSignal account. You can also refer detail document here for setting up - https://github.com/geektimecoil/react-native-onesignal

  3. [ ] 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.

  4. [ ] You can also send the push notification manually through the OneSignal admin.

  5. [ ] ### Enable app opening instead of browser

    Open your child template folder or create new mu-plugin (https://www.sitepoint.com/wordpress-mu-plugins/\ then paste these code to enable the app push notification

// config for one Signal

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);

results matching ""

    No results matching ""