ios - UILocalnotification 未在 iOS7 中显示
<p><p>也许我遗漏了一些东西,但据我所知,我做得对。我正在尝试安排本地通知,但它似乎永远不会显示。我运行应用程序,然后点击主页按钮。 15 秒后,角标(Badge)更新为 1,但我从未看到警报。</p>
<p>我在 ViewController 的 viewDidLoad 中的代码是:</p>
<pre><code>.applicationIconBadgeNumber = 0;
NSDate *currentDate = ;
NSDate *targetDate = ; //15 seconds
UILocalNotification *localNotification = [ init];
localNotification.fireDate = targetDate;
localNotification.timeZone = ;
localNotification.alertBody = @"Body!";
localNotification.alertAction = @"Action!";
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.applicationIconBadgeNumber = 1;
[ scheduleLocalNotification:localNotification];
</code></pre>
<p>如果应用程序正在运行,我确实会接到电话:</p>
<pre><code>-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
</code></pre>
<p>有什么想法吗?据我所知,这一切都得到了正确的处理。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我发现我未能注册通知。 </p>
<p>添加这个:</p>
<pre><code> [registerForRemoteNotificationTypes:
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound];
</code></pre>
<p>解决了我的问题。 </p></p>
<p style="font-size: 20px;">关于ios - UILocalnotification 未在 iOS7 中显示,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/20176867/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/20176867/
</a>
</p>
页:
[1]