2017-09-14 103 views
0

我有以下的命令,我讓我的通知在iOS中,我希望得到我的鑰匙通知鍵更我沒有得到它,我的嘗試是接收來自IOS

public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler) 
    { 
     Messaging.SharedInstance.AppDidReceiveMessage(userInfo); 

     NSString[] keys = { new NSString("Event_type") }; 
     NSObject[] values = { new NSString("Recieve_Notification") }; 
     var parameters = NSDictionary<NSString, NSObject>.FromObjectsAndKeys(keys, values, keys.Length); 

     Firebase.Analytics.Analytics.LogEvent("CustomEvent", parameters); 

     System.Diagnostics.Debug.WriteLine(userInfo); 

     // var aps_d = userInfo["aps"] as NSDictionary; 
     //var alert_d = aps_d["alert"] as NSDictionary; 
     //var body = alert_d["keys"] as NSString; 
    } 

System.Diagnostics程序.Debug.WriteLine 收到此

[0:] { 
aps =  { 
    alert =   { 
     body = "teste"; 
     title = "teste"; 
    }; 
}; 
"gcm.message_id" = "0:1505400569099941%712ac0f8712a1234"; 
"gcm.n.e" = 1; 
"google.c.a.c_id" = 5974019197827881234; 
"google.c.a.c_l" = "teste"; 
"google.c.a.e" = 1; 
"google.c.a.ts" = 1505400123; 
"google.c.a.udt" = 0; 
keys = 152113; 
} 

回答

1

keys在字典中的頂層,最後一個條目,這樣你就可以通過userInfo["keys"]直接訪問它,即:

var keys = userInfo["keys"] as NSString;