0
当我收到我的推送通知时,从我的应用程序委托我处理handleRemoteNotifications:(NSDictionary *)userInfo
中的推送,并从那里我调用firstViewController
类方法来发送推送url,如下所示:无法从我的Web视图控制器加载推送URL
-(void)handleRemoteNotifications:(NSDictionary *)userInfo {
// get link
NSDictionary *aps = (NSDictionary *)[userInfo objectForKey:@"aps"];
if ([aps objectForKey:@"link"])
{
NSString* jobID = [NSString stringWithFormat:@"%@",[aps objectForKey:@"link"]];
NSLog(jobID,nil);
[FirstViewController viewController:jobID];
}
}
这是我firstViewController.h:
#import <UIKit/UIKit.h>
@interface FirstViewController : UIViewController <UIWebViewDelegate>
@property (readwrite, strong, nonatomic) IBOutlet UIWebView *firstview;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *back;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *stop;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *refresh;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *forward;
+(void)viewController:(NSString*)link;
- (void)updateButtons;
@end
一个我试图加载接收推URL在当前web视图这样的:
+(void)viewController:(NSString*)link{
NSURL *url = [NSURL URLWithString:link];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
FirstViewController *new = [[FirstViewController alloc]init];
[new loadPush:(NSURLRequest*)requestObj];
}
-(void)loadPush:(NSURLRequest*)requestObj{
[_firstview loadRequest:requestObj];
}
一切工作正常,当我编译,除了URL不加载。我究竟做错了什么?
我已经做到了,链接没问题。我认为这是因为我正在创建一个viewController的新实例,但我不知道该怎么做...... – user3033437