极光推送 推送处理总结 点击通知跳转
来源:互联网 发布:java格式化日期24小时 编辑:程序博客网 时间:2024/06/10 16:44
当应用处于杀死状态的时候,通过点击通知内容开启APP 此时只需在 (位于后台的时候点击通知内容不会走这个方法)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
]方法中判断launchOptions是否为空
例如:
if (launchOptions !=nil) {// 不是空 就是推送点击 否则是图标启动
NSDictionary* remoteNotification = [launchOptionsobjectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if ([[UIDevicecurrentDevice].systemVersionfloatValue] < 10.0) {
// iOS 10 不必走此方法[selfreciveNotification:remoteNotification];// 处理推送跳转方法 详见下方
}
}
#pragma mark iOS 6 以下收到推送
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[JPUSHServicehandleRemoteNotification:userInfo];
//pushDic = userInfo;
//[selfreciveNotificationAlertShow];
}
iOS 7 及以上10以下 收到推送及点击处理
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
[JPUSHServicehandleRemoteNotification:userInfo];
if (application.applicationState == UIApplicationStateActive) {
// 如果是前台运行出现弹窗
pushDic = userInfo;
// 前台收到推送出现弹窗
[selfreciveNotificationAlertShow];
}else{
// 处于后台 的点击
[self reciveNotification:userInfo];
}
completionHandler(UIBackgroundFetchResultNewData);
}
#pragma mark iOS 10 前台收到通知(远程推送和本地通知)
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification*)notification withCompletionHandler:(void (^)(NSInteger))completionHandler {
NSDictionary * userInfo = notification.request.content.userInfo;
if([notification.request.triggerisKindOfClass:[UNPushNotificationTriggerclass]]) {
/// iOS10处理远程推送
[JPUSHServicehandleRemoteNotification:userInfo];
pushDic = userInfo;
// 前台出弹窗提示
[self reciveNotificationAlertShow];
}else{
/// iOS10处理本地通知添加到通知栏
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert);
}
// 需要执行这个方法,选择是否提醒用户,有Badge、Sound、Alert三种类型可以选择设置
}
当APP 无论运行于后台时,杀死 点击通知内容 开启APP 会走这个方法 这要在这个方法中处理推送跳转
iOS 10
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler {
// Required
NSDictionary * userInfo = response.notification.request.content.userInfo;
if([response.notification.request.triggerisKindOfClass:[UNPushNotificationTriggerclass]]) {
// 推送处理
[JPUSHServicehandleRemoteNotification:userInfo];
[selfreciveNotification:userInfo];
}else{
// 本地通知处理
}
completionHandler(); // 系统要求执行这个方法
}
// APP前台弹窗提示
- (void )reciveNotificationAlertShow{
}
// APP杀死和后台时 推送点击的跳转处理- (void)reciveNotification:(NSDictionary *)pushdic{
// 点击推送之后广告页消失
HuoDongXiangQingViewController *hdxqVC = [[HuoDongXiangQingViewControlleralloc]init];
hdxqVC.hidesBottomBarWhenPushed =YES;
// 获取当前停留的controler 进行push
[[selfcurrentViewController].navigationControllerpushViewController:hdxqVCanimated:YES];
}
#pragma mark 获取当前的停留的VC用来实现任意页面跳转到指定页面
- (UIViewController *)currentViewController{
UIViewController *currVC =nil;
UIViewController *Rootvc =self.window.rootViewController;
do{
if ([RootvcisKindOfClass:[UINavigationControllerclass]]) {
UINavigationController *nav = (UINavigationController *)Rootvc;
UIViewController *v = [nav.viewControllerslastObject];
currVC = v;
Rootvc = v.presentedViewController;
continue;
}elseif ([RootvcisKindOfClass:[UITabBarControllerclass]]){
UITabBarController *tabvc = (UITabBarController *)Rootvc;
currVC = tabvc;
Rootvc = [tabvc.viewControllersobjectAtIndex:tabvc.selectedIndex];
continue;
}
}while (Rootvc !=nil);
return currVC;
}
// APP 处于前台的时候 推送通知点击创建alertview 点击跳转方法和杀死 后台运行状态处理方法相同
- (void)reciveNotificationAlertShow{
UIAlertView *alert = [[UIAlertViewalloc]initWithTitle:@"提示"message:@"收到热门推送"delegate:selfcancelButtonTitle:@"取消"otherButtonTitles:@"查看",nil];
[alert show];
}
获取当前页的方法也可以使用
- (UIViewController *)topVC:(UIViewController *)rootViewController{
if ([rootViewControllerisKindOfClass:[UITabBarControllerclass]]) {
UITabBarController *tab = (UITabBarController *)rootViewController;
return [selftopVC:tab.selectedViewController];
}elseif ([rootViewControllerisKindOfClass:[UINavigationControllerclass]]){UINavigationController *navc = (UINavigationController *)rootViewController;
return [selftopVC:navc.visibleViewController];
}elseif (rootViewController.presentedViewController){
UIViewController *pre = (UIViewController *)rootViewController.presentedViewController;
return [selftopVC:pre];
}else{
return rootViewController;
}
}
使用方法
UIViewController *vc = [selftopVC:[UIApplicationsharedApplication].keyWindow.rootViewController];
huodong.hidesBottomBarWhenPushed =YES;
[vc.navigationControllerpushViewController:huodonganimated:YES];
TBMoiveViewController* currentView = [[TBMoiveViewControlleralloc]init];
// 创建导航栏
FLGNanViewController *nanVC = [[FLGNanViewControlleralloc]initWithRootViewController:currentView];
[self.window.rootViewControllerpresentViewController:nanVCanimated:YEScompletion:^{
}];
- 极光推送 推送处理总结 点击通知跳转
- 极光推送怎么点击通知跳转页面?
- 极光推送点击跳转问题
- 极光推送-点击通知栏跳到指定页面
- 极光推送注册、接收、点击打开推送通知
- iOS极光推送 点击推送消息跳转页面
- 【iOS开发】iOS极光推送 点击推送消息跳转页面
- iOS极光推送 点击推送消息跳转页面
- iOS极光推送 点击推送消息跳转页面
- iOS极光推送 点击推送消息跳转页面
- iOS极光推送 点击推送消息跳转页面
- iOS极光推送 点击推送消息跳转页面
- iOS APNS 极光推送 点击通知栏跳转应用相应页面
- 极光推送页面跳转
- 极光推送通知和消息
- 极光推送和通知栏
- iOS 极光推送接收通知
- iOS 关于信鸽推送点击推送通知的处理
- iOS定时器,指定时间后触发。
- ssh传输文件
- ioS应用性能调优的25个建议和技巧(8)
- linux命令持续学习
- Android开发-------设置系统状态栏颜色
- 极光推送 推送处理总结 点击通知跳转
- IBM管网DataStage数据整合学习参考地址
- LCD和VS6760分辨率设置
- Java Web 排错日记
- React Native 界面入门 for WebStorm
- 编码与解码
- spring MVC多视图配置
- Cornerstone的使用
- 树变二叉树结点数计算