Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/112.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
Iphone 推送通知警报查看操作?_Iphone_Ios_Ipad_Apple Push Notifications - Fatal编程技术网

Iphone 推送通知警报查看操作?

Iphone 推送通知警报查看操作?,iphone,ios,ipad,apple-push-notifications,Iphone,Ios,Ipad,Apple Push Notifications,我有一个iphone应用程序,其中我正在以alertview的形式执行推送通知。当我的应用程序处于后台状态时,推送通知就会出现,当我点击它或解锁手机时,它将直接进入应用程序,我将其保持在forground状态。我使用点击查看按钮在警报中添加操作,它将进入另一个视图控制器。我不想在点击通知时进入应用程序。我需要显示alertview和点击查看按钮,我需要执行操作。有人能帮我实现吗?这是我的代码片段`- - (void)application:(UIApplication *)application

我有一个iphone应用程序,其中我正在以alertview的形式执行推送通知。当我的应用程序处于后台状态时,推送通知就会出现,当我点击它或解锁手机时,它将直接进入应用程序,我将其保持在forground状态。我使用点击查看按钮在警报中添加操作,它将进入另一个视图控制器。我不想在点击通知时进入应用程序。我需要显示alertview和点击查看按钮,我需要执行操作。有人能帮我实现吗?这是我的代码片段`-

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    //check application in forground or background
    if(application.applicationState == UIApplicationStateActive)
    {
        //NSLog(@"FOreGround");
        //NSLog(@"and Showing %@",userInfo)
    }
    else
    {   
        NSDictionary *curDict= [userInfo objectForKey:@"aps"];
        UIAlertView *connectionAlert = [[UIAlertView alloc] initWithTitle:@"app" message:[NSString stringWithFormat:@"%@",[curDict objectForKey:@"alert"]] delegate:self cancelButtonTitle:@"View" otherButtonTitles:@"Cancel",nil];
        [connectionAlert show];
        [connectionAlert release];
        [UIApplication sharedApplication].applicationIconBadgeNumber =[[curDict objectForKey:@"badge"] intValue];   
    }
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    NSLog(@"applicationWillEnterForeground");
    [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSString *title = [alertView buttonTitleAtIndex:buttonIndex];

    if ([title isEqualToString:@"View"]) 
    {   
        NSArray *mycontrollers = self.tabBarController.viewControllers;
        NSLog(@"%@",mycontrollers);
        [[mycontrollers objectAtIndex:0] popToRootViewControllerAnimated:NO];
        mycontrollers = nil;  
        tabBarController.selectedIndex = 0;
    }
}

您向用户显示UIAlertView,当收到通知时,将调用DidReceiveMemoteNotification:函数

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
    {
        NSLog(@"userInfo :%@",userInfo);

        NSString* msg = [userInfo valueForKey:@"aps"];

        if (self._VCObj.isViewLoaded && self._VCObj.view.window) {
                // viewController is visible don't show.
        }
            else { // viewController is not visible
                [[[UIAlertView alloc]initWithTitle:@"Title" message:msg delegate:self cancelButtonTitle:@"ok" otherButtonTitles: nil] show];
            }
        }
    }

对不起,你能说得更准确些吗?您不想在触摸通知时进入应用程序?那根本不可能。。。