2012-07-18 71 views
0

我有一個應用程序,我添加推送notification.I顯示推送通知作爲aletview.with兩個按鈕視圖和cancell.i需要當用戶點擊視圖按鈕我需要去特定的viewcontroller .can有人幫我實現嗎?這我怎麼用notification.`做如何將操作添加到pushnotification alertview?

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { 

    NSLog(@"########################################didReceiveRemoteNotification****************************###################### %@",userInfo); 
    //check application in forground or background 
    if(application.applicationState == UIApplicationStateActive) 
    { 
     //NSLog(@"FOreGround"); 
     //////NSLog(@"and Showing %@",userInfo) 
    } 
    else { 

     NSDictionary *curDict= [userInfo objectForKey:@"aps"]; 
     UIAlertView *connectionAlert = [[UIAlertView alloc] initWithTitle:@"app" message:[NSString stringWithFormat:@"%@",[curDict objectForKey:@"alert"]] delegate:self cancelButtonTitle:@"View" otherButtonTitles:@"Cancel",nil]; 
     [connectionAlert show]; 
     [connectionAlert release]; 
     [UIApplication sharedApplication].applicationIconBadgeNumber =[[curDict objectForKey:@"badge"] intValue]; 



    } 


} 

`

回答

1

你只需要執行UIAlertViewDelegate並調用委託方法

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    switch(buttonIndex) { 
    case 0: // do something 
     break; 
    case 1: // do something else 
     break; 
    } 
} 
+0

我是這樣做的appdeleg ate.is有可能在此添加? – hacker 2012-07-18 14:28:44

+0

是的,這是可能的 – 2012-07-18 14:30:23

相關問題