How to get One Signal unique user id in Mobile?

Parama Sudha picture Parama Sudha · Apr 2, 2016 · Viewed 36.1k times · Source

I am developing a restaurant app. I am using One Signal in my app to send notifications. Here while I place the order I need to send the unique Id of the one signal for a specific user for getting notification of "Your Order is placed successfully... It is in Progress.Please wait". For that I need the user's One Signal user id. How can I get it? I am newbie to One Signal. Please help me.

Answer

Parama Sudha picture Parama Sudha · Apr 2, 2016

Got the unique Id of OneSignal by using the following code which is in official site of OneSignal.

OneSignal.idsAvailable(new OneSignal.IdsAvailableHandler() {
        @Override
        public void idsAvailable(String userId, String registrationId) {
            Log.d("debug", "User:" + userId);
            if (registrationId != null)
                Log.d("debug", "registrationId:" + registrationId);

        }
    });

Refer:

Getting code in Official Site

This Above Code is Deprecated. Please use the below code.

String UUID = OneSignal.getPermissionSubscriptionState().getSubscriptionStatus().getUserId()