OneSignal / OneSignal-Cordova-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Ionic, PhoneGap CLI, PhoneGap Build, Cordova, or Sencha Touch app with OneSignal. Supports Android, iOS, and Amazon's Fire OS platforms. https://onesignal.com
Other
251 stars 198 forks source link

Do not subscribe users in OneSignal with versions of Android 5 or higher #208

Closed PterPmnta closed 7 years ago

PterPmnta commented 7 years ago

I'm integrating the push-notifications in my hybrid application developed in Ionic v1, but I have encountered a somewhat strange problem, and is that users with android version 5 or higher are not subscribing to the OneSignal platform.

I have a phone that has Android 4.2.2, and everything works to normal, subscribes, and everything works. Some days ago, you could subscribe to a phone which proved that it had Android 6.0.1, but then stopped, and the same with Android 5, which already performed the test.

Tests made to deduce and problem

Even so, the problem persists, they do not subscribe to the platform.

Changes made in the app

Code

  // Add to index.js or the first page that loads with your app.
    // For Intel XDK and please add this to your app.js.

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

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

        window.plugins.OneSignal
        .startInit('862b34cb-f0ba-4ab3-89b7-bf7d84e85162')
        .handleNotificationOpened(notificationOpenedCallback)
        .endInit();

        // Call syncHashedEmail anywhere in your app if you have the user's email.
        // This improves the effectiveness of OneSignal's "best-time" notification scheduling feature.
        // window.plugins.OneSignal.syncHashedEmail(userEmail);
    }, false);

Note: I do not want the subscription to perform at the moment of starting the application, since no one should receive them, if it is not logged in.

jkasten2 commented 7 years ago

@PterPmnta OneSignal should always be initialized with the start of your app as a number of things depend on this. This includes the SDK ensure the push token is up to date, session counts and duration, and state is synced including tags.

You can set kOSSettingsKeyAutoPrompt to false with iOSSettings so the user does not get prompted right away by initializing OneSignal. So Android users are not auto subscribed you can call setSubscription with false.

Confirming the Android 5 and 6 issue. Your test devices are no longer subscribing even when you fully uninstall and re-install the app on the device? Can you try calling OneSignal.setLogLevel with logLevel set to 6 and check for any errors? Feel free to attach the logcat here or send it to OneSignal support to look it over.

PterPmnta commented 7 years ago

@jkasten2 i solved, create a new project with Ionic 1, and check the config.xml, and see the path and other configs.

jkasten2 commented 7 years ago

@PterPmnta Good to hear!