Limit "category" for local notifications with devices >= ios8

This commit is contained in:
Guillaume BIENKOWSKI 2014-10-03 16:15:46 +02:00
parent 645a8a6969
commit a7e7093163
2 changed files with 29 additions and 22 deletions

View file

@ -425,26 +425,29 @@
}
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void (^)())completionHandler {
LinphoneCore* lc = [LinphoneManager getLc];
[LinphoneLogger log:LinphoneLoggerLog format:@"%@", NSStringFromSelector(_cmd)];
if( [notification.category isEqualToString:@"incoming_call"]) {
if( [identifier isEqualToString:@"answer"] ){
// use the standard handler
[self application:application didReceiveLocalNotification:notification];
} else if( [identifier isEqualToString:@"decline"] ){
LinphoneCall* call = linphone_core_get_current_call(lc);
if( call ) linphone_core_decline_call(lc, call, LinphoneReasonDeclined);
}
} else if( [notification.category isEqualToString:@"incoming_msg"] ){
if( [identifier isEqualToString:@"reply"] ){
// use the standard handler
[self application:application didReceiveLocalNotification:notification];
} else if( [identifier isEqualToString:@"mark_read"] ){
NSString* from = [notification.userInfo objectForKey:@"from"];
LinphoneChatRoom* room = linphone_core_get_or_create_chat_room(lc, [from UTF8String]);
if( room ){
linphone_chat_room_mark_as_read(room);
[[PhoneMainView instance] updateApplicationBadgeNumber];
if( [[UIDevice currentDevice].systemVersion floatValue] >= 8){
LinphoneCore* lc = [LinphoneManager getLc];
[LinphoneLogger log:LinphoneLoggerLog format:@"%@", NSStringFromSelector(_cmd)];
if( [notification.category isEqualToString:@"incoming_call"]) {
if( [identifier isEqualToString:@"answer"] ){
// use the standard handler
[self application:application didReceiveLocalNotification:notification];
} else if( [identifier isEqualToString:@"decline"] ){
LinphoneCall* call = linphone_core_get_current_call(lc);
if( call ) linphone_core_decline_call(lc, call, LinphoneReasonDeclined);
}
} else if( [notification.category isEqualToString:@"incoming_msg"] ){
if( [identifier isEqualToString:@"reply"] ){
// use the standard handler
[self application:application didReceiveLocalNotification:notification];
} else if( [identifier isEqualToString:@"mark_read"] ){
NSString* from = [notification.userInfo objectForKey:@"from"];
LinphoneChatRoom* room = linphone_core_get_or_create_chat_room(lc, [from UTF8String]);
if( room ){
linphone_chat_room_mark_as_read(room);
[[PhoneMainView instance] updateApplicationBadgeNumber];
}
}
}
}

View file

@ -670,7 +670,9 @@ static void linphone_iphone_display_status(struct _LinphoneCore * lc, const char
data->timer = [NSTimer scheduledTimerWithTimeInterval:4.0 target:self selector:@selector(localNotifContinue:) userInfo:data->notification repeats:TRUE];
data->notification.repeatInterval = 0;
data->notification.category = @"incoming_call";
if( [[UIDevice currentDevice].systemVersion floatValue] >= 8){
data->notification.category = @"incoming_call";
}
data->notification.alertBody =[NSString stringWithFormat:NSLocalizedString(@"IC_MSG",nil), address];
data->notification.alertAction = NSLocalizedString(@"Answer", nil);
data->notification.soundName = @"shortring.caf";
@ -895,7 +897,9 @@ static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyCo
UILocalNotification* notif = [[[UILocalNotification alloc] init] autorelease];
if (notif) {
notif.repeatInterval = 0;
notif.category = @"incoming_msg";
if( [[UIDevice currentDevice].systemVersion floatValue] >= 8){
notif.category = @"incoming_msg";
}
notif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"IM_MSG",nil), address];
notif.alertAction = NSLocalizedString(@"Show", nil);
notif.soundName = @"msg.caf";