2011-06-11 38 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即将推出的东西会改变,下载测试版,并看看。

相关问题