Fix new notification handling behavior for messages

This commit is contained in:
Guillaume BIENKOWSKI 2014-09-22 14:31:10 +02:00
parent b12262b01e
commit 733405e0c6
3 changed files with 10 additions and 7 deletions

View file

@ -427,25 +427,27 @@
}
- (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([LinphoneManager getLc]);
if( call ) linphone_core_decline_call([LinphoneManager getLc], call, LinphoneReasonDeclined);
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"] ){
LinphoneChatRoom* room = [[notification.userInfo objectForKey:@"room"] pointerValue];
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];
}
}
}
completionHandler();

View file

@ -871,7 +871,7 @@ static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyCo
if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]
&& [UIApplication sharedApplication].applicationState != UIApplicationStateActive) {
const LinphoneAddress* remoteAddress = linphone_chat_message_get_from(msg);
const LinphoneAddress* remoteAddress = linphone_chat_message_get_from_address(msg);
char* c_address = linphone_address_as_string_uri_only(remoteAddress);
NSString* address = [NSString stringWithUTF8String:c_address];
NSString* from_address = [address copy];
@ -894,11 +894,11 @@ static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyCo
UILocalNotification* notif = [[[UILocalNotification alloc] init] autorelease];
if (notif) {
notif.repeatInterval = 0;
notif.category = @"@incoming_msg";
notif.category = @"incoming_msg";
notif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"IM_MSG",nil), address];
notif.alertAction = NSLocalizedString(@"Show", nil);
notif.soundName = @"msg.caf";
notif.userInfo = @{@"from":from_address, @"room":[NSValue valueWithPointer:room] };
notif.userInfo = @{@"from":from_address};
[[UIApplication sharedApplication] presentLocalNotificationNow:notif];

View file

@ -73,6 +73,7 @@
- (void)addInhibitedEvent:(id)event;
- (BOOL)removeInhibitedEvent:(id)event;
- (void)updateApplicationBadgeNumber;
+ (PhoneMainView*) instance;
@end