0
I have in my android application the service Onesignal working properly, so far so good. I want to make some modifications to my Sharepreference (database) each time I receive a message. I managed to do such action while the app is in the foreground, however in the background the action does not work. I would like you to help me solve this problem. Follow the code that works first prano
public class mIntentService extends IntentService {
public mIntentService() {
super("notification");
}
@Override
protected void onHandleIntent(@Nullable Intent intent) {
// OneSignal Initialization
OneSignal.startInit(MyApplication.getAppContext())
.setNotificationReceivedHandler(new NotificationReceivedHandler())
.inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
.unsubscribeWhenNotificationsAreDisabled(true)
.init();
Log.i("notification", "O IntentService foi iniciado");
}
public class NotificationReceivedHandler implements OneSignal.NotificationReceivedHandler {
@Override
public void notificationReceived(OSNotification notification) {
//Essa é a função após receber a notificação
LibraryIO io = new LibraryIO(getApplicationContext());
io.setBooleanIO("iconNotificationNews", true);
Log.i("iconNotificationNews", "iconNotificationNews chamadado");
}
}
}
Note that I tried to play in a service, but still do not understand how it works.