iOS 本地通知 操作
ios 操作 本地 通知
2023-09-11 14:15:06 时间
iOS 本地通知 操作
1:配置通知:然后退出程序;
UILocalNotification *localNotif = [[UILocalNotification alloc] init]; localNotif.fireDate = date; // date after 10 sec from now localNotif.timeZone = [NSTimeZone defaultTimeZone]; // Notification details localNotif.alertBody = text; // text of you that you have fetched // Set the action button localNotif.alertAction = @"View"; localNotif.soundName = UILocalNotificationDefaultSoundName; localNotif.applicationIconBadgeNumber = 1; // Specify custom data for the notification NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"someValue" forKey:@"someKey"]; localNotif.userInfo = infoDict; // Schedule the notification [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
2:接收通知,打开操作
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. // Add the view controller's view to the window and display. [window addSubview:viewController.view]; [window makeKeyAndVisible]; application.applicationIconBadgeNumber = 0; // Handle launching from a notification UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; if (localNotif) { NSLog(@"Recieved Notification %@",localNotif); } return YES; } - (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif { // Handle the notificaton when the app is running NSLog(@"Recieved Notification %@",notif); }
相关文章
- 【iOS】网络操作与AFNetworking
- 《iOS应用逆向工程:分析与实战》
- ios多线程操作(四)—— GCD核心概念
- iOS 线程操作库 PromiseKit
- IOS事件处理机制(关于触发者和响应者的确认)
- iOS开发技巧 - 使用UIDatePicker来选择日期和时间
- 《iOS应用开发》——1.2节启程
- NSDictionary字典创建,获取,遍历,可变字典的删除 - iOS
- iOS开发拓展篇——如何把项目托管到GitHub
- iOS 应用开发中的断点续传实践总结
- iOS修改声明为readonly的属性值
- IOS-图片操作集合
- iOS 原生二维码扫描和生成
- SwiftUI iOS 组件之支持拖拽全屏sheet组件(教程含源码)
- iOS 播放远程网络音乐的核心技术点
- iOS中WebKit框架应用与解析
- iOS 打开扬声器以及插入耳机的操作
- 【读书笔记】iOS-Xcode-模拟器操作的一些快捷键
- iOS开发 - Xcode9打包的三个新选项含义
- iOS开发 - 不小心删除了Copy Bundle Resources怎么办?(多人开发频繁添加删除图片导致图片路径重复,编译报错)
- iOS - Core Animation(核心动画)
- iOS开发之网络编程--4、NSURLSessionDataTask实现文件下载(离线断点续传下载) <进度值显示优化>