2017-03-17 107 views
0

我试图将通知的iOS处理程序迁移到Firebase服务器。在appDelegate.cs文件,在xamarin网站(https://components.xamarin.com/gettingstarted/firebaseioscloudmessaging)的步骤之一的文档是这样的:针对iOS的Xamarin Firebase云消息传递(appDelegate)RemoteMessageDelegate错误

// 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(); 

两行代码中,messaging.sharedinstance ....和UNUSerNotificationCenter.Current ...收到appdelegate的工作量。为了使appdelegate实现Usernotificationcenterdelegate,这是有效的。但是,这不适用于Firebase邮件代理。 Firebase消息委托未被识别。我已经安装了云消息传递包(v1.2.1.1),分析(3.6.0),核心(3.4.5)和实例标识(1.0.8)。这些包通过Nuget包管理器安装。

任何人有一个想法,为什么FIRMessagingDelegate找不到,或者是否有某些特定的需要完成这些版本的iOS包?

回答

1

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); 
    } 

    ~~~~ 
} 
+0

我需要知道究竟是什么!谢谢! 显然,“ApplicationReceivedRemoteMessage”函数已经在“入门”文档中声明,但更多的伪装在代码中。应该重写,说实话,解决这个问题! – RiccardoM

相关问题