打开通知警报后加载Web视图?

时间:2014-09-04 22:00:27

标签: objective-c uiwebview push-notification uialertview url-redirection

我制作了一个RSS应用程序,它运行得很好,我还添加了推送通知支持,到目前为止一切都很好,我传递了一个标题,警报和一个网址作为额外的字段。

当我的通知到达时,我会显示警报,并且您有两个选项“Thanx | Open”

我现在要做的就是,当您点击此警告中的“打开”时,我需要将用户重定向到具有UIwebview的视图,并加载我传递的通知的网址。

任何人都可以帮助我吗?

这是我的代码:

// here is my app delegate 

    -(void)onReceivePushNotification:(NSDictionary *) pushDict andPayload:(NSDictionary *)payload {
        [payload valueForKey:@"title"];
        UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"New Alert !" message:[pushDict valueForKey:@"alert"] delegate:self cancelButtonTitle:@"Thanks !" otherButtonTitles: @"Open",nil];

        NSLog(@"message was : %@", [pushDict valueForKey:@"alert"]);
        NSLog(@"url was : %@", [payload valueForKey:@"url"]);
        [message show];
    }
    -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
    {
        NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
        if([title isEqualToString:@"Open"]) {
            [[Pushbots getInstance] OpenedNotification];
            // Decrease Badge count by 1
            [[UIApplication sharedApplication] setApplicationIconBadgeNumber:[UIApplication sharedApplication].applicationIconBadgeNumber -1];
            // Decrease badge count on the server
            [[Pushbots getInstance] decreaseBadgeCountBy:@"1"];

            [[NSNotificationCenter defaultCenter] postNotificationName:@"updateRoot" object:nil];
        } else {
            // set Badge to 0
            [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
            // reset badge on the server
            [[Pushbots getInstance] resetBadgeCount];
        }
    }

我的详细信息视图名为:“APPDetailViewController”,其网页视图名为“webView”

请帮帮我? 提前谢谢。

1 个答案:

答案 0 :(得分:0)

您可以在clickedButtonAtIndex方法中创建APPDetailViewController的实例并显示它。如果你有标签,你可以切换到该标签,然后有一个方法来传递网址,以便打开该页面。