更新Firebase软件包后,“InstanceID”不包含“SetApnsToken”的定义

问题描述 投票:1回答:1

在我的Xamarin.iOS项目中,我更新了Firebase nuget包,在完成更新后,我开始在此代码上收到错误

//You'll need this method if you set "FirebaseAppDelegateProxyEnabled": NO in GoogleService-Info.plist
public override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken)
{
    SISConst.PushInfo = new PushNotification();
    SISConst.PushInfo.DeviceID = deviceToken.ToString();
    NSUserDefaults.StandardUserDefaults.SetString(deviceToken.ToString(),"dToken");

#if DEBUG
    Firebase.InstanceID.InstanceId.SharedInstance.SetApnsToken(deviceToken, Firebase.InstanceID.ApnsTokenType.Sandbox);
#if RELEASE
    Firebase.InstanceID.InstanceId.SharedInstance.SetApnsToken(deviceToken, Firebase.InstanceID.ApnsTokenType.Prod);
}

下面的行显示错误

Firebase.InstanceID.InstanceId.SharedInstance.SetApnsToken(deviceToken, Firebase.InstanceID.ApnsTokenType.Sandbox);

有关更多信息,请参阅截图

enter image description here

我该如何解决这个问题?

ios firebase xamarin xamarin.ios firebase-cloud-messaging
1个回答
2
投票

挣扎了几个小时后得到了答案

if DEBUG
            Firebase.CloudMessaging.Messaging.SharedInstance.SetApnsToken(deviceToken, ApnsTokenType.Sandbox);
endif
if RELEASE
            Firebase.CloudMessaging.Messaging.SharedInstance.SetApnsToken(deviceToken,ApnsTokenType.Production);
endif
© www.soinside.com 2019 - 2024. All rights reserved.