Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
远程通知Ios_Ios_Objective C_Push Notification - Fatal编程技术网

远程通知Ios

远程通知Ios,ios,objective-c,push-notification,Ios,Objective C,Push Notification,我已经在我的应用程序中实现了推送通知 我收到的AP如下: { aps = { alert = "Bhai kaisa hai notification a rha hai!"; customtitle = "Customtitle here"; keyid = 8; sound = default; }; } 我想将keyid和customtitle传递给视图控制器我的代码: NSString * ti

我已经在我的应用程序中实现了推送通知

我收到的AP如下:

{
    aps =     {
        alert = "Bhai kaisa hai notification a rha hai!";
        customtitle = "Customtitle here";
        keyid = 8;
        sound = default;
    };
}
我想将keyid和customtitle传递给视图控制器我的代码:

  NSString * titletopass = [userInfo objectForKey:@"customtitle"];
    NSString * keytopass = [userInfo objectForKey:@"keyid"];

    //NSString *titletopass=[getpass objectForKey:@"customtitle"];
    PostsDetailsViewController *obj = [[PostsDetailsViewController alloc]init];

    obj.Viewtitle = titletopass;
    obj.key=keytopass;

   NSString *identifier;
    identifier=@"postsdetails";
    UIStoryboard *    storyboardobj=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
    obj = [storyboardobj instantiateViewControllerWithIdentifier:identifier];
    [self.window setRootViewController:obj];
它不会将数据传递给viewcontroller,并且keytopass+titletopass也是空的


提前感谢。

obj
设置为
PostDetailsViewController
的实例后,您将
obj
设置为从情节提要实例化的
postdetails
视图控制器

如果您打算使用故事板,那么您应该仅从中创建实例。拥有实例后,可以设置属性

例如:

NSString * titletopass = [[userInfo objectForKey:@"aps"] objectForKey:@"customtitle"];
NSString * keytopass = [[userInfo objectForKey:@"aps"] objectForKey:@"keyid"];

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
PostsDetailsViewController *obj = (PostDetailsViewController *)[storyboard instantiateViewControllerWithIdentifier:@"postdetails"];

obj.Viewtitle = titletopass;
obj.key=keytopass;

[self.window setRootViewController:obj];

obj
设置为
postdailsviewcontroller
的实例后,将
obj
设置为从情节提要实例化的
postdails
视图控制器

如果您打算使用故事板,那么您应该仅从中创建实例。拥有实例后,可以设置属性

例如:

NSString * titletopass = [[userInfo objectForKey:@"aps"] objectForKey:@"customtitle"];
NSString * keytopass = [[userInfo objectForKey:@"aps"] objectForKey:@"keyid"];

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
PostsDetailsViewController *obj = (PostDetailsViewController *)[storyboard instantiateViewControllerWithIdentifier:@"postdetails"];

obj.Viewtitle = titletopass;
obj.key=keytopass;

[self.window setRootViewController:obj];

我无法从我的{aps={alert=“Bhai kaisa hai!”编辑答案的customtitle=“customtitle here”;keyid=8;sound=default;};}中获取标题内容。您在
aps
对象中拥有这些属性。我无法从我的“{aps={alert=“Bhai kaisa hai notification a rha hai!”;customtitle=“customtitle here”;keyid=8;sound=default;};}”编辑的答案中获取titletopass。您在
aps
对象中拥有这些属性。