Reputation: 11
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));
};
window.plugins.OneSignal.init("11111111-1111-1111-1111-111111111111",
{googleProjectNumber: "1111111111111"},
notificationOpenedCallback);
// Show an alert box if a notification comes in when the user is in your app.
window.plugins.OneSignal.enableInAppAlertNotification(true);
}, false);
I installed the "onesignal-cordova-plugin
Upvotes: 1
Views: 1080
Reputation: 3948
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.
Upvotes: 1