In my app, I have some push notification subscribers (OneSignal). I am trying to get the user id's like this:
OneSignal.GetIdsAvailable(IdsAvailable);
....
....
private void IdsAvailable(string userID, string pushToken)
{
playeridx = userID;
System.Diagnostics.Debug.WriteLine("UserID:" + userID);
System.Diagnostics.Debug.WriteLine("pushToken:" + pushToken);
}
But I get an error: "OneSignal does not contain a definition for GetIdsAvailable."
Any ideas?
As I am seeing, we must use the code bellow to get the UserID. But, which event is triggered when the UserID arrives from Onesignal? if I use the UserID right after this line, it always has the UserID? It sounds strange for me, because, sometimes it could not had received the UserID yet.
It looks like you are using a method found in the OneSignal Windows SDK. If you want to do this in Unity, setup the Unity SDK (if you haven't done so already) and then perhaps use GetPermissionSubscriptionState to retrieve the
userId
andpushToken
of the current user, instead of using.GetIdsAvailable()
.