0

当用户从本地通知中点击查看按钮而不打开发送通知的我的应用程序时,是否可以执行操作(例如使用 URL 方案打开另一个应用程序)?

一个例子:
我发送了一个带有 alertText“检查你的网站”的本地通知。用户收到通知,按下视图,Safari 会自动打开,而无需打开我的应用程序。

我知道当我的应用程序打开并使用 URL 方案打开 safari 时可以立即检查该做什么,但我认为这样做不太舒服,因为用户每次都会看到我的应用程序打开。

提前感谢您的回答,如果我的问题无法立即理解,对不起(我不是本地人)

拉莱

4

2 回答 2

0

不,你不能。

按下“查看”​​按钮将触发您的应用程序。也许随着新的 iOS 5 即将到来,一些事情会发生变化,下载测试版并看看。

于 2011-06-11T18:07:45.430 回答
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];
}
于 2011-06-11T12:57:36.100 回答