【问题标题】:'InstanceID' does not contain definition for 'SetApnsToken' after updating Firebase packages更新 Firebase 软件包后,“InstanceID”不包含“SetApnsToken”的定义
【发布时间】:2019-07-06 00:34:43
【问题描述】:

在我的 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);

更多信息请参考截图

我该如何解决这个问题?

【问题讨论】:

  • 你可以这样设置 ApnsToken。如果有帮助,请在此处查看我的答案stackoverflow.com/questions/53078653/…
  • 我没有收到SetApnsToken。不知道它在哪个命名空间下。我收到ApnsTokenType。谢谢。
  • [FIRMessaging 消息].APNSToken = deviceToken;这样你就可以设置 APNSToken。你看不出来吗?
  • 您好,刚刚得到答复。 Xamarin 几乎没有不同的语法或包。感谢您的支持。看看我的回答。

标签: ios firebase xamarin xamarin.ios firebase-cloud-messaging


【解决方案1】:

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

if DEBUG
            Firebase.CloudMessaging.Messaging.SharedInstance.SetApnsToken(deviceToken, ApnsTokenType.Sandbox);
endif
if RELEASE
            Firebase.CloudMessaging.Messaging.SharedInstance.SetApnsToken(deviceToken,ApnsTokenType.Production);
endif

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-29
    相关资源
    最近更新 更多