2012-02-21 218 views
2

如果我的應用程序被關閉,而iPhone收到該應用程序的推送通知,它將接收並打開應用程序?推送通知IOS

謝謝

回答

7

如果沒有收到消息時,它不會打開的應用程序。

您的應用程序WIL得到,如果用戶選擇查看通知啓動。 因此,如果用戶不響應通知,您的應用程序將不會啓動。

如果您的應用程序已經在運行,並在前臺比應用程序的委託將直接收到通知。

+0

這是正確的答案。通知不會處理應用程序管理,就像打開它們一樣。 – Yorxxx 2012-02-21 11:50:30

1

時通報白羊座那個時候你打開你可以使用下面的代碼的應用程序。

- (void)applicationDidEnterBackground:(UIApplication *)application 
{ 
    UILocalNotification *localNotification = [[[UILocalNotification alloc] init] autorelease]; 

    // Current date 
    NSDate *date = [NSDate date]; 

    // Add one second to the current time 
    NSDate *dateToFire = [date dateByAddingTimeInterval:1]; 

    // Set the fire date/time 
    [localNotification setFireDate:dateToFire]; 
    [localNotification setTimeZone:[NSTimeZone defaultTimeZone]];  

    // Setup alert notification 
    [localNotification setAlertBody:@"Tap to return to TestApp" ]; 
    [localNotification setAlertAction:@"Open TestApp"]; 
    [localNotification setHasAction:YES]; 

    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 
} 

而且關於這件事你can use Refer the Reference.

願此代碼有助於你更多的信息。

1

是,當您收到推送 - 它顯示爲上出現在頂部屏幕上的警告(你可以選擇設置的方式)的消息,這將在幾秒鐘後消失。如果你點擊推送通知 - 它會打開應用程序。但是,當您收到推送時,應用程序將不會在接收推送時自動打開。只有在用戶點擊推送後。