Unfortunately I have a problem with OneSignal for Ionic.

What is working?:
- iOS and Android devices accept push messages fine
- Users show up on Onesignal admin panel just fine
- I can manually opt-in and opt-out (using window.plugins.OneSignal.setSubscription(true/false);)
- On iOS I receive a popup asking me to opt-in for push messages.

What is not working:
- I do not receive the popup on Android devices asking me to opt-in. All users are automatically opt-in ;-) I spent a few hours reading stackoverflow, onesignal user manuals but no solution is provided.

My app.js

document.addEventListener('deviceready', function () {
  // Enable to debug issues.
  // window.plugins.OneSignal.setLogLevel({logLevel: 4, visualLevel: 4});

  var notificationOpenedCallback = function(jsonData) {
    console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));

                                 {googleProjectNumber: "1111111111111"},

  // Show an alert box if a notification comes in when the user is in your app.
}, false);

I installed the "onesignal-cordova-plugin

1 Answers 11

Android users are automatically opted into OneSignal push notifications. If you would like to ask permission first you can call OneSignal.setSubscription(false); after OneSignal.init(...) to keep them from being opted in automatically. Then display your own in app prompt where you call OneSignal.setSubscription(true); if they accept.

Not the answer you're looking for? Browse other questions tagged or ask your own question.