我必须在收到推送通知后将我的phonegap应用程序重定向到特定的html页面。我不知道如何从pbjective c代码中做到这一点。
我想做那样的事情:
答案 0 :(得分:0)
您应该创建新的视图控制器,UIWebView的子类(您可以在故事板中执行),然后在-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
中获取该视图控制器将您的URL作为参数传递它应该没问题,让我们说你在navigationController里面有你的网页视图,你可以这样做:
UINavigationController *navigationController = (UINavigationController*)_window.rootViewController;
YourWebViewController *webViewController =
(YourWebViewController*)[navigationController.viewControllers objectAtIndex:0];
// pass url as a parameter (you have to create property first in your YourWebViewController class)
webViewController.urlToOpen = [NSURL URLWithString:@"http://www.google.com"];
请记住,添加到didFinishLaunchingWithOptions是很好的:
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// ...
if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {
[self application:application didReceiveRemoteNotification:launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]];
}
}