Xamarin Firebase Cloud Messaging for iOS (appDelegate) Remot



我正在尝试将用于通知的 iOS 处理程序迁移到 Firebase 服务器。在 appDelegate.cs 文件中,有关 xamarin 站点 (https://components.xamarin.com/gettingstarted/firebaseioscloudmessaging( 的文档步骤之一如下所示:

// Register your app for remote notifications.
if (UIDevice.CurrentDevice.CheckSystemVersion (10, 0)) {
    // iOS 10 or later
    var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;
    UNUserNotificationCenter.Current.RequestAuthorization (authOptions, (granted, error) => {
        Console.WriteLine (granted);
    });
    // For iOS 10 display notification (sent via APNS)
    UNUserNotificationCenter.Current.Delegate = this;
    // For iOS 10 data message (sent via FCM)
    Messaging.SharedInstance.RemoteMessageDelegate = this;
} else {
    // iOS 9 or before
    var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
    var settings = UIUserNotificationSettings.GetSettingsForTypes (allNotificationTypes, null);
    UIApplication.SharedApplication.RegisterUserNotificationSettings (settings);
}
UIApplication.SharedApplication.RegisterForRemoteNotifications ();

两行代码,消息传递.共享实例....和联合国驻地通知中心。接收应用程序委托工作负载。为了使应用程序委托实现用户通知中心委托,这是有效的。但是,这不适用于 Firebase 消息委托。Firebase 消息委托无法识别。我已经安装了云消息传递包 (v1.2.1.1(、分析 (3.6.0(、核心 (3.4.5( 和实例 ID (1.0.8(。这些包通过 Nuget 包管理器安装。

有人知道为什么找不到FIRMessagingDelegate,或者需要为这些版本的iOS软件包做一些具体的事情吗?

FIRMessagingDelegate被命名为IMessagingDelegate

[Protocol (Name = "FIRMessagingDelegate", WrapperType = typeof(MessagingDelegateWrapper)), ProtocolMember (IsRequired = true, IsProperty = false, IsStatic = false, Name = "ApplicationReceivedRemoteMessage", Selector = "applicationReceivedRemoteMessage:", ParameterType = new Type[] {
 typeof(RemoteMessage) }, ParameterByRef = new bool[] { false }), Introduced (PlatformName.iOS, 10, 0, PlatformArchitecture.None, null)]
public interface IMessagingDelegate : INativeObject, IDisposable
{
  ~~~

在您的UIApplicationDelegate上实施IMessagingDelegate

[Register("AppDelegate")]
public class AppDelegate : UIApplicationDelegate, IMessagingDelegate
{
    ~~~~
    public void ApplicationReceivedRemoteMessage(RemoteMessage remoteMessage)
    {
       Console.WriteLine(remoteMessage);
    }
    ~~~~
}

相关内容

  • 没有找到相关文章

最新更新