2015-04-28 38 views
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不加載。我究竟做錯了什麼?

回答

-1

你可以把NSURL * url後的NSLog測試鏈接字符串,並檢查NSURL不是零?然後,如果您收到一個好的URL,請嘗試在瀏覽器上進行測試。

編輯:

也許你對新的視圖控制器實例化添加網頁視圖。

UIWebView *webView = [[UIWebView alloc]  initWithFrame:self.view.bounds]; 

self.webView = webView; 

[self.view addSubview:self.webView]; 
+0

我已經做到了,鏈接沒問題。我認爲這是因爲我正在創建一個viewController的新實例,但我不知道該怎麼做...... – user3033437

相關問題