Monotouch:获得NSDictionary值

时间:2012-07-05 00:07:21

标签: c# ios mono xamarin.ios push-notification

我有远程通知字典,但如何取出AlertBody?

NSDictionary remoteNotification = options 
     [UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
来自remoteNotification的

3 个答案:

答案 0 :(得分:2)

        var k = new Object[] {"key"};
        var v = new Object[] {"value"};
        NSDictionary a = NSDictionary.FromObjectsAndKeys(v,k);
        NSObject value = a[NSObject.FromObject("key")];

你可以试试这个对我有用....

答案 1 :(得分:2)

这对我有用:

发送推送通知:

oPushService.QueueNotification(NotificationFactory.Apple()
    .ForDeviceToken("YourDeviceTokenASDASD!@#SDF")
    .WithCustomItem("MyCustomItem","Item 3")
    .WithAlert("Alert pop message")
    .WithSound("default")
    .WithBadge(7))); 

在客户端:

void processNotification(NSDictionary options, bool fromFinishedLaunching) {                   
(options != null && options.ContainsKey(new NSString("aps"))) {    
    NSDictionary alertMsg = options; 
    NSObject codeCustomValue = alertMsg[NSObject.FromObject("MyCustomItem")];
    // .... and continue your code....  }

希望它有所帮助!

Armando

答案 2 :(得分:0)

这取决于您发送给应用程序的内容。基本上,这是您发送的JSON请求转换为NSDictionary表单。