0

My Json

{
aps =     {
    alert =         {
        body = "This is a testing message !!!";
        title = Notification;
    };
};
data = "{\"push_type\":6,\"badge\":1,\"alert\":\"This is a testing message !!!\",\"sound\":\"default\",\"content-available\":\"1\",\"is_login\":2}";
"gcm.message_id" = "0:1494478903994917%6c350cc06c350cc0"; }

I want to get push_type like here it is 6.

My code is:

NSDictionary *data=[[userInfo valueForKey:@"data"] valueForKey:@"push_type"]];

After run this line an error occur push_type is not key value coding complaints...

Could you please help me where i am wrong,or how can i achieve this,please refer me an example,link thanks!

vky
  • 475
  • 1
  • 6
  • 14

1 Answers1

3

Try with it.

NSString *jsonString=[[userInfo valueForKey:@"data"];

NSData *JsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];

NSDictionary *data = [NSJSONSerialization JSONObjectWithData:JsonData options:0 error:nil];

Now from "data" dictionary you can get any value from its key, like "push_type" etc...

Piyush
  • 1,534
  • 12
  • 32
  • dear patel i aleardy accept that... could you guide me about one thing ..?? my push notification working fine on ios version <10 but now i have a device its version is 10.2,here only this device notification not received,what changes are required for ios 10,please refer an example or link...Thanks – vky May 11 '17 at 06:53
  • Refer : http://stackoverflow.com/questions/39267549/ios-how-to-integrate-push-notification-in-ios-10 – Piyush May 11 '17 at 06:58
  • dear i already done that steps but still not receiving notification o ios 10 – vky May 11 '17 at 07:06