AppDelegate.m
#pragma mark --關(guān)閉APP時(shí)執(zhí)行此方法
- (void)applicationWillTerminate:(UIApplication*)application
{
// Called when the application is about
to terminate. Save data if appropriate. See also
applicationDidEnterBackground:.
[[EaseMobsharedInstance]applicationWillTerminate:application];
UILocalNotification*noti = [[UILocalNotificationalloc]init];
if(noti) {
//設(shè)置時(shí)區(qū)
noti.timeZone= [NSTimeZonedefaultTimeZone];
//設(shè)置重復(fù)間隔
noti.repeatInterval=0;
//推送聲音
noti.soundName=UILocalNotificationDefaultSoundName;
//內(nèi)容
noti.alertBody=@"為了保證定位服務(wù)正常運(yùn)行,請(qǐng)運(yùn)行程序并保持在后臺(tái)運(yùn)行!";
//設(shè)置userinfo方便在之后需要撤銷的時(shí)候使用
NSDictionary*infoDic = [NSDictionarydictionaryWithObject:@"name"forKey:@"key"];
noti.userInfo= infoDic;
//立即觸發(fā)一個(gè)通知
[[UIApplicationsharedApplication]presentLocalNotificationNow:noti];
}
}