2011-06-11 58 views
0

當用戶從本地通知中點擊查看按鈕而不打開發送該應用程序的應用程序時,是否可以執行操作(例如打開另一個具有URL方案的應用程序)通知?當用戶從本地通知點擊「查看」時執行操作

一個例子:
我送與alertText「檢查您的網站」本地通知。 用戶獲取通知,按下視圖,Safari不會自動打開我的應用程序。

我知道可以立即檢查當我的應用程序打開時要做什麼,並用URL方案打開Safari,但我認爲這樣做並不舒服,因爲用戶每次看到我的應用程序都會打開。

感謝提前和對不起你的答案,如果我的問題是不理解立即(我可不是本地)

拉萊

回答

0

要收聽這些類型的事件,您可以使用這些功能之一:

// On iOS 4.0+ only, listen for background notification 

if(&UIApplicationDidEnterBackgroundNotification != nil) 
{ 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(function) name:UIApplicationDidEnterBackgroundNotification object:nil]; 
} 

// Register for notification when the app shuts down 

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(function) name:UIApplicationWillTerminateNotification object:nil]; 

// On iOS 4.0+ only, listen for foreground notification 

if(&UIApplicationWillEnterForegroundNotification != nil) 
{ 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(function) name:UIApplicationWillEnterForegroundNotification object:nil]; 
} 
+0

感謝您的回答,但這些事件只是告訴我,我回到了應用程序,輸入背景等等,不是嗎? 他們也不告訴我我是否來自通知。我想要的是通過直接轉到另一個應用程序而不是我的應用程序來繞過此方法。當您安排通知時,按下查看按鈕時無法設置功能如何操作?拉萊 – LaleMuc 2011-06-11 13:34:30

0

不,你不能。

按「查看」按鈕將觸發您的應用程序。 也許隨着新的iOS 5即將推出的東西會改變,下載測試版,並看看。