push-notificationonesignalgenexusgenexus-sd

java.lang.IllegalStateException: Object NotificationsRegistrationHandler only supports OFFLINE but is being called via RemoteApplicationServer


I´m getting this error when procedure NotificationsRegistrationHandler is executed at application startup.

java.lang.IllegalStateException: Object NotificationsRegistrationHandler only supports OFFLINE but is being called via RemoteApplicationServer

As documentation says:

If you have a completely offline application and you need this Registration Handler procedure to be generated offline exclusively, set Main property = False and Connectivity Support property = Offline

I have set my main SD object Registration Handler property to use this procedure.

I have also set the following properties on procedure NotificationsRegistrationHandler:

enter image description here

What it´s wrong with my code or configuration?

Thanks, Rogelio Arosemena


Solution

  • I found an alternative solution by creating an external object on Android to return One Signal Id. The code was:

    OneSignal.idsAvailable(new OneSignal.IdsAvailableHandler() {
    @Override
    public void idsAvailable(String userId, String registrationId) {
    try{
    return userId;
    }catch(Exception e){                    
    e.printStackTrace();
    return "";
    }
    }
    });
    

    Device registration on One Signal was ok on SD application. The problem was that procedure NotificationRegistrationHandler was never executed (offline or online), so we can't store DeviceToken on our table.

    We will have to do the same for IOS with this code:

    OSPermissionSubscriptionState status = OneSignal.getPermissionSubscriptionState();
    
    status.getSubscriptionStatus().getUserId();