【发布时间】:2014-09-04 22:00:27
【问题描述】:
我制作了一个 RSS 应用程序,它运行良好,我还添加了推送通知支持,到目前为止一切都很好,正在传递标题、警报和 url 作为额外字段。
当我的通知到达时,我会显示我的警报,并且您有 2 个选项“Thanx | 打开”
我现在要做的就是,当您在此警报中单击打开时,我需要将我的用户重定向到具有 UIwebview 的视图并加载我与通知一起传递的 url。
谁能帮帮我?
这是我的代码:
// 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”的网络视图
请帮帮我? 提前致谢。
【问题讨论】:
标签: objective-c uiwebview push-notification uialertview url-redirection