[问题] 请问推波的判定

楼主: larry122 (larry122)   2016-07-14 00:35:13
各位好,小弟最近遇到一个有关于推播的问题,
目前可以当APP在前台收到推波时将一个viewcontroller的view addsubview上去,
也可以在背景或是尚未执行的时候点推波讯息,能够顺利打开app并将view展现出来,
但只要使用者在背景或是尚未开启app的时候是直接点选桌面上的icon,
view将不会被贴上去,想请问是这做法不可行还是我还没找到方向呢!?
目前部分code如下
ps.目前还有一个问题是BadgeNumber的问题,如何让收到推波的时候+1 并只要有开启或
正在开启的时number就为0呢)
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSDictionary *remoteNotif = [launchOptions objectForKey:
UIApplicationLaunchOptionsRemoteNotificationKey];
// Accept push notification when app is not open
if (remoteNotif) {
[self handleRemoteNotification:application
didReceiveRemoteNotification:remoteNotif];
}
}
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo {
if([[userInfo objectForKey:@"aps"] objectForKey:@"alert"]!=NULL){
NSString *alertbody = [[userInfo objectForKey:@"aps"]
objectForKey:@"alert"];
UIStoryboard* mainStoryboard = [UIStoryboard
storyboardWithName:@"Main" bundle: nil];
AlertCustumViewController * view1 = [mainStoryboard
instantiateViewControllerWithIdentifier:@"alert"];
[self.window addSubview:view1.view];
application.applicationIconBadgeNumber =
application.applicationIconBadgeNumber+1;
}
}
-(void)handleRemoteNotification:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo {
UIStoryboard* mainStoryboard = [UIStoryboard storyboardWithName:@"Main"
bundle: nil];
AlertCustumViewController * view1 = [mainStoryboard
instantiateViewControllerWithIdentifier:@"alert"];
[self.window addSubview:view1.view];
}
作者: howdiun (Howdiun)   2016-07-14 09:19:00
像line点推播会开那一页,直接点icon就不会,大家都一样
作者: LFimi   2016-07-14 09:27:00
开启app之后将applicationIconBadgeNumber设为0就好
楼主: larry122 (larry122)   2016-07-14 10:13:00
感谢 我上班只能手机回文 目前对badge想法是数字是再didReviceRemoteNotification +1 然后didFinishLauchingwithOption归0 我来测看看
作者: songooo (songooo)   2016-07-14 11:25:00
可考虑在applicationWillEnterForeground归0可能要把原本app就在背景时的状况考虑进去
楼主: larry122 (larry122)   2016-07-14 12:07:00
感谢楼上 目前是用becomeactive归0 下午测试您的方法看看所以点icon目前似乎是无解
作者: jazzter (阿里巴巴你妈妈)   2016-07-14 14:20:00
应该说,你如果要改变app进入时的状态是不能单仰赖推播的,它本身就不是个可靠的data source,建议你如真有这需求用,改用其它方式手机推文断句很乱歹势
楼主: larry122 (larry122)   2016-07-14 15:08:00
了解 感谢您 我也是手机推文乱断行

Links booklink

Contact Us: admin [ a t ] ucptt.com