ios - 查找启动应用程序 : banner notification, 警报通知或图标点击的事件?
<p><p>我可以找出在 iOS 上启动应用程序的事件吗?</p>
<p>我需要区分以下几点:</p>
<ol>
<li>点击图标</li>
<li>横幅通知</li>
<li>警报通知</li>
</ol>
<p>或者,我可以查看应用程序本地设置(设置为横幅或警报通知)吗?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>要确定应用是否通过按下通知启动,您需要实现 2 个方法。</p>
<p>首先,在应用程序 didFinishLaunchingWithOptions 中,执行以下操作:</p>
<pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
if () {
// Handle notification
}
</code></pre>
<p>第二:</p>
<pre><code>-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
if (application.applicationState == UIApplicationStateActive) {
// The app was open when a remote notification was received...
} else {
// The app was in the background and just came to the foreground in response to the user pressing the push notification
}
</code></pre>
<p>}</p>
<p>您可以使用以下方式查看已启用的通知类型:</p>
<pre><code>UIRemoteNotificationType notificationTypes = [ enabledRemoteNotificationTypes];
</code></pre>
<p>但是,您无法区分横幅通知或警报通知。</p></p>
<p style="font-size: 20px;">关于ios - 查找启动应用程序 : banner notification, 警报通知或图标点击的事件?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/11134775/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/11134775/
</a>
</p>
页:
[1]