当前位置: 首页 > news >正文

网站建设的建议例子黎平网站开发

网站建设的建议例子,黎平网站开发,国内室内设计师,超炫网站iOS开发-NotificationServiceExtension实现实时音视频呼叫通知响铃与震动 在之前的开发中#xff0c;遇到了实时音视频呼叫通知#xff0c;当App未打开或者App在后台时候#xff0c;需要通知到用户#xff0c;用户点击通知栏后是否接入实时音视频的视频或者音频通话。 在…iOS开发-NotificationServiceExtension实现实时音视频呼叫通知响铃与震动 在之前的开发中遇到了实时音视频呼叫通知当App未打开或者App在后台时候需要通知到用户用户点击通知栏后是否接入实时音视频的视频或者音频通话。 在iOS需要为工程新建TargetNotificationServiceExtension 一、主工程配置 需要在主工程中开启推送功能配置证书。 二、新建NotificationServiceExtension的target 新建NotificationServiceExtension的target 三、实现NotificationService 在NotificationService的方法 // 主要代码 - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler- (void)serviceExtensionTimeWillExpire;在didReceiveNotificationRequest实现呼叫响铃及震动效果。 // 通过通知的Sound设置为voip_call.caf这里播放一段空白音频音频结束后结束震动NSString *path [[NSBundle mainBundle] pathForResource:blank_call.mp3 ofType:nil];AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path], soundID);AudioServicesAddSystemSoundCompletion(soundID, NULL, NULL, soundCompleteCallback, NULL);AudioServicesAddSystemSoundCompletion(kSystemSoundID_Vibrate, NULL, NULL, soundCompleteCallback, NULL);完整代码如下 #import NotificationService.h #import AVFoundation/AVFAudio.h #import AVFoundation/AVFoundation.h #import AudioToolbox/AudioToolbox.hinterface NotificationService () {SystemSoundID soundID; }property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver); property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;property (nonatomic, strong) NSMutableArray *requests;endimplementation NotificationService- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {self.contentHandler contentHandler;self.bestAttemptContent [request.content mutableCopy];BOOL playVoice NO;NSString *chatPushVo [self.bestAttemptContent.userInfo objectForKey:chatPushVo];if (chatPushVo [chatPushVo isKindOfClass:[NSString class]] chatPushVo 0) {NSDictionary *dict [self dictionaryWithJsonString:chatPushVo];if (dict [dict isKindOfClass:[NSDictionary class]]) {NSString *type [NSString stringWithFormat:%, [dict objectForKey:type]];// type 0 呼叫if ([0 isEqualToString:type]) {playVoice YES;// 通过通知的Sound设置为voip_call.caf这里播放一段空白音频音频结束后结束震动NSString *path [[NSBundle mainBundle] pathForResource:blank_call.mp3 ofType:nil];AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path], soundID);AudioServicesAddSystemSoundCompletion(soundID, NULL, NULL, soundCompleteCallback, NULL);AudioServicesAddSystemSoundCompletion(kSystemSoundID_Vibrate, NULL, NULL, soundCompleteCallback, NULL);[self playVoiceWithContent:self.bestAttemptContent.userInfo];}}}if (playVoice NO) {self.contentHandler(self.bestAttemptContent);} }- (void)playVoiceWithContent:(NSDictionary *)userInfo {// iOS 10之前前台没有通知栏// 此处调用之前的语音播报的内容[self playRegisterNotifications:userInfo]; }- (void)playRegisterNotifications:(NSDictionary *)userInfo {[self registerNotifications:userInfo]; }- (void)registerNotifications:(NSDictionary *)userInfo {[self startShakeSound]; }/// 开始响铃 - (void)startShakeSound {// 声音AudioServicesPlaySystemSound(soundID);// 震动AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);self.contentHandler(self.bestAttemptContent); }/// 结束响铃 - (void)stopShakeSound {AudioServicesDisposeSystemSoundID(soundID);AudioServicesRemoveSystemSoundCompletion(soundID); }//AudioServicesAddSystemSoundCompletion的回调函数 void soundCompleteCallback(SystemSoundID sound,void * clientData) {if (sound kSystemSoundID_Vibrate) {AudioServicesPlayAlertSound(sound);//重复响铃震动} else {// 移除AudioServicesDisposeSystemSoundID(sound);AudioServicesRemoveSystemSoundCompletion(sound);AudioServicesDisposeSystemSoundID(kSystemSoundID_Vibrate);AudioServicesRemoveSystemSoundCompletion(kSystemSoundID_Vibrate);} }- (void)serviceExtensionTimeWillExpire {// Called just before the extension will be terminated by the system.// Use this as an opportunity to deliver your best attempt at modified content, otherwise the original push payload will be used.self.contentHandler(self.bestAttemptContent); }/**json转成NSDictionaryparam jsonString json字符串return NSDictionary*/ - (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString {if (jsonString nil) {return nil;}NSData *jsonData [jsonString dataUsingEncoding:NSUTF8StringEncoding];NSError *err;NSDictionary *dic [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:err];if(err) {return nil;}return dic; }end四、使用推送 我这里使用的极光推送注意需要设置推送的mutable-content1字段。 五、点击通知后处理是否通实时音视频视频通话 在收到通知后用户点击点击通知后处理是否通实时音视频视频通话逻辑。 在AppDelegate的方法 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions增加didReceiveRemoteNotification // 获取启动时收到的APNNSDictionary *userInfo [[DFPushManager shareInstance] launchOptionsRemoteNotification:launchOptions];if (userInfo) {[self application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:^(UIBackgroundFetchResult result) {}];}当收到通知后在didReceiveRemoteNotification中处理是否接通实时音视频的视频通话的逻辑 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {DFDebugLogger(didReceiveRemoteNotification);[[SDPushManager shareInstance] handleRemoteNotification:application userInfo:userInfo completion:nil];NSLog(收到通知:%, userInfo);[[SDPushManager shareInstance] setBadgeNumberMax:nil];if ([UIApplication sharedApplication].applicationState ! UIApplicationStateActive) {// 登录后调用check__weak typeof(self) weakSelf self;if (userInfo [userInfo isKindOfClass:[NSDictionary class]]) {NSString *chatPushVo [userInfo objectForKey:chatPushVo];if (chatPushVo [chatPushVo isKindOfClass:[NSString class]] appPushVo.length 0) {NSDictionary *dict [DFJsonUtil dictionaryWithJsonString: chatPushVo];if (dict [dict isKindOfClass:[NSDictionary class]]) {NSString *type [NSString stringWithFormat:%, [dict objectForKey:type]];// type 0 呼叫/// 0/用户呼叫// 打开接听页面进行接听}}}}completionHandler(UIBackgroundFetchResultNewData); }六、小结 iOS开发-NotificationServiceExtension实现实时音视频呼叫通知与语音播报 在之前的开发中遇到了实时音视频呼叫通知当App未打开或者App在后台时候需要通知到用户用户点击通知栏后是否接入实时音视频的视频或者音频通话。 学习记录每天不停进步。
http://www.hkea.cn/news/14525563/

相关文章:

  • python做网站的书哪里建设网站不需要备案
  • 住房和城乡建设部注册中心网站中国空间站建造历程
  • 网站推广营销怎么做广州网站建设出名 乐云践新
  • 网站里面的链接怎么做的珠海室内设计学校
  • 网站制作温州大英哪里有做网站的
  • 厦门专业做网站的公司销售网站有哪些
  • 做网站的那些高清图上哪里找广州市番禺区
  • 网站开发与设计实训巴中市建设厅官方网站
  • 织梦怎么制作手机网站聚美优品网站建设产品策略
  • 网站加v怎么做安徽网新科技网站建设介绍
  • 为什么自己做的网站uc打不开徐州城乡建设招投标网站
  • 哪个网站可以做破案h5沌口开发区网页设计
  • 做网站都需要考虑哪些网站网站开发犯法吗
  • 网站怎么做分享链接wordpress 调用别名
  • 公司招聘网站续费申请做网站什么笔记本好用
  • 有深度网站企业微信小程序制作
  • html5电影网站设计论文wordpress扁平化博客主题
  • 企业网站排名提升软件网络营销策略制定
  • 北京做网站建设的公司有哪些浏览器一打开就是2345网址导航
  • 与建设通相关的网站网站建设咨询电话
  • 网站建设加推广话术点击精灵seo
  • 阿里云网站建设程序杭州产品推广服务公司
  • 简单网站建设合同模板沧州 中企动力提供网站建设
  • 云空间可以做网站网站建设0doit
  • 太原北京网站建设公司男女做恩爱视频网站
  • 做个网站多少费用大连万词推广
  • 泉州做网站优化价格网站建设销售技巧
  • 水果网站策划书北京注册公司流程
  • 潍坊网站建设价格低建站费用参考
  • 商丘专业做网站公司推广任务发布平台app