2017-03-17 54 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

相關問題