如何在iOS中創(chuàng)建本地通知?我想知道如何設(shè)置本地通知,以便在我設(shè)置時,我的應(yīng)用程序生成帶有自定義消息的通知/警報...
3 回答

當(dāng)年話下
TA貢獻(xiàn)1890條經(jīng)驗 獲得超9個贊
在appdelegate.m文件中,在applicationDidEnterBackground中編寫以下代碼以獲取本地通知
- (void)applicationDidEnterBackground:(UIApplication *)application{ UILocalNotification *notification = [[UILocalNotification alloc]init]; notification.repeatInterval = NSDayCalendarUnit; [notification setAlertBody:@"Hello world"]; [notification setFireDate:[NSDate dateWithTimeIntervalSinceNow:1]]; [notification setTimeZone:[NSTimeZone defaultTimeZone]]; [application setScheduledLocalNotifications:[NSArray arrayWithObject:notification]];}
- 3 回答
- 0 關(guān)注
- 718 瀏覽
添加回答
舉報
0/150
提交
取消