菜鸟教程小白 发表于 2022-12-12 09:47:16

ios - 本地通知问题


                                            <p><p>我正在尝试在数组日期与当前日期相同时收到通知,此代码用于此任务</p>

<pre><code>NSDateFormatter *Form = [ init];
    ;

    UILocalNotification *notification = [ init];
    for (int i=0;i&lt;_convertedBdates.count;i++)
    {
      NSDate *date =];
      NSLog(@&#34;date%@&#34;,date);

    if(notification)
      {
            notification.fireDate = date;
            notification.timeZone = ;
            notification.alertBody = @&#34;New &#34;;
            notification.alertAction = @&#34;View&#34;;

            notification.soundName = UILocalNotificationDefaultSoundName;
            notification.applicationIconBadgeNumber = 1;
            [ scheduleLocalNotification:notification];
      }
    }
</code></pre>

<p>建议我做错了什么</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您是否已将此代码放入您的应用委托(delegate)中?</p>

<pre><code> - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
    NSLog(@&#34;Notification Received, %@, set for date %@&#34;, notification.alertBody, notification.fireDate);
}
</code></pre>

<p>如果问题仍然存在,那么我就在这里 :)</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 本地通知问题,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/15516332/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/15516332/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 本地通知问题