Unity-从OneSignal获取ID

时间:2018-06-25 17:00:24

标签: unity3d onesignal

获取Onesignal用户ID的正确方法是什么?

OSPermissionSubscriptionState state = OneSignal.GetPermissionSubscriptionState();
extraMessage = " UserId: "+state.subscriptionStatus.userId;

此方法对我来说有点奇怪,因为ID到达时没有调度事件。如何确定该应用程序已经具有ID?

1 个答案:

答案 0 :(得分:1)

我找到了。

OneSignal.subscriptionObserver += OneSignal_subscriptionObserver;

private void OneSignal_subscriptionObserver(OSSubscriptionStateChanges stateChanges)
{
    extraMessage = "OneSignal_subscriptionObserver UserId: " + stateChanges.to.userId;
}