2017-03-17 1 views
0

알림을 위해 iOS 처리기를 firebase 서버로 마이그레이션하려고합니다. appDelegate.cs 파일에서 자 마린 사이트 단계 (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 workload를 받는다. appdelegate가 Usernotificationcenterdelegate를 구현하게하려면이 방법이 유용합니다. 그러나 이것은 Firebase 메시지 대리인에게는 작동하지 않습니다. firebase 메시지 델리게이트가 인식되지 않습니다. 클라우드 메시징 패키지 (v1.2.1.1), 분석 (3.6.0), 코어 (3.4.5) 및 인스턴스 ID (1.0.8)를 설치했습니다. 이 패키지는 Nuget 패키지 관리자를 통해 설치됩니다.

FIRMessagingDelegate를 찾을 수없는 이유가 있거나,이 버전의 iOS 패키지에서 수행해야 할 특정 작업이 있습니까?

답변

1

FIRMessagingDelegateIMessagingDelegate 이름 :

[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 
{ 
    ~~~ 

UIApplicationDelegateIMessagingDelegate 구현 :

[Register("AppDelegate")] 
public class AppDelegate : UIApplicationDelegate, IMessagingDelegate 
{ 
    ~~~~ 

    public void ApplicationReceivedRemoteMessage(RemoteMessage remoteMessage) 
    { 
     Console.WriteLine(remoteMessage); 
    } 

    ~~~~ 
} 
+0

을 내가 알 필요가 정확히 무엇을! 감사! 분명히 "ApplicationReceivedRemoteMessage"함수는 "시작하기"문서에서 이미 선언되었지만 코드에서 더 많이 위장되었습니다. 솔직히이 문제를 해결하기 위해 다시 작성해야합니다! – RiccardoM

관련 문제