2014-03-12 27 views
0

嗨,我正在開發一個應用程序,其中我推送通知激活。我使用parse.com。到目前爲止,我的工作已經完成,我可以發送通知,設備也會收到通知,而且我還會在應用中獲得徽章。我從通知中輸入應用程序時設置了一個AlertView。但我不知道如何在UIAlertView中顯示推送通知的文本。而且我還希望徽章在您查看郵件時消失。下面是使用代碼即時通訊:在UIAlertView中顯示推送通知的內容

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 
{ 
if (application.applicationState == UIApplicationStateInactive) 
{ 
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Text" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; 

    [alert show]; 
} 
else if (application.applicationState == UIApplicationStateActive) 
{ 
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Text" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; 

    [alert show]; 
} 
} 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 

{ 
    NSDictionary * pushDictionary = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; 

    if (pushDictionary) 
    { 
     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Text" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; 

     [alert show]; 
    } 
} 
+0

[識別推送通知消息(HTTP的可能重複: //stackoverflow.com/questions/12294214/identifying-the-push-notification-message) – javierfdezg

回答

0

要處理的推送通知,並顯示警報查看其信息嘗試的appDelegate:

- (void)application:(UIApplication *)application 
didReceiveRemoteNotification:(NSDictionary *)userInfo {  
    [PFPush handlePush:userInfo]; 
}