I am integrating notifications-push in my hybrid application developed in Ionic v1, but I have contracted with a slightly strange problem, and that is that users with android version 5 or higher are not are subscribing to the OneSignal platform.
I have a phone which has Android 4.2.2, and everything works to normal, it is subscribed, and everything works. A few days ago, you could subscribe to a phone which proved that you had Android 6.0.1, but then stopped doing it, and the same with Android 5, which already performs the test.
Tests done to deduce the problem
- Create a new app as well as FCM as well as OneSignal ,
- Change the respective keys and the number of the new project generated on the platform
- Change the values also on the server and in the app
Even so, the problem persists, they do not subscribe to the platform.
Changes made in the app
- The user after going through a kind of filter, where he wondered if he was a student or teacher, to then execute the subscription, and go to the corresponding menu. (The error persists for Android 5 or higher, there is no subscription)
- Then, subscribe them when the application, redirect when you reach the menu, since then, the view would always be active, and the file containing the subscription code, would be always active (Error persists for Android 5 or higher).
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);
The code is taken from the same OneSignal guide
Note: I do not want the subscription to be made at the moment of starting the application, since nobody should receive them, if it is not logged .