Allow to show messages in notifications, and answer it inline in iOS9.

This commit is contained in:
Guillaume BIENKOWSKI 2015-12-17 16:03:19 +01:00
parent e702b0f8e5
commit 8d694d22ad
6 changed files with 40 additions and 9 deletions

View file

@ -30,6 +30,7 @@
}
- (void)processRemoteNotification:(NSDictionary*)userInfo;
- (void)registerForNotifications:(UIApplication *)app;
@property (nonatomic, retain) UIAlertView *waitingIndicator;
@property (nonatomic, retain) NSString *configURL;

View file

@ -127,7 +127,8 @@
mark_read.authenticationRequired = NO;
NSArray *actions;
if ([[UIDevice.currentDevice systemVersion] floatValue] < 9) {
if ([[UIDevice.currentDevice systemVersion] floatValue] < 9 ||
[LinphoneManager.instance lpConfigBoolForKey:@"show_msg_in_notif"] == NO) {
actions = @[ mark_read, reply ];
} else {
// iOS 9 allows for inline reply. We don't propose mark_read in this case
@ -167,14 +168,8 @@
return localRingNotifAction;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIApplication *app = [UIApplication sharedApplication];
UIApplicationState state = app.applicationState;
LinphoneManager *instance = LinphoneManager.instance;
BOOL background_mode = [instance lpConfigBoolForKey:@"backgroundmode_preference"];
BOOL start_at_boot = [instance lpConfigBoolForKey:@"start_at_boot_preference"];
- (void)registerForNotifications:(UIApplication *)app {
LinphoneManager *instance = [LinphoneManager instance];
if ([app respondsToSelector:@selector(registerUserNotificationSettings:)]) {
/* iOS8 notifications can be actioned! Awesome: */
@ -191,12 +186,25 @@
[app registerForRemoteNotifications];
}
} else {
/* iOS7 and below */
if (!instance.isTesting) {
NSUInteger notifTypes =
UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge;
[app registerForRemoteNotificationTypes:notifTypes];
}
}
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIApplication *app = [UIApplication sharedApplication];
UIApplicationState state = app.applicationState;
LinphoneManager *instance = [LinphoneManager instance];
BOOL background_mode = [instance lpConfigBoolForKey:@"backgroundmode_preference"];
BOOL start_at_boot = [instance lpConfigBoolForKey:@"start_at_boot_preference"];
[self registerForNotifications:app];
if (state == UIApplicationStateBackground) {
// we've been woken up directly to background;
@ -461,6 +469,7 @@
if (room) {
LinphoneChatMessage *msg = linphone_chat_room_create_message(room, replyText.UTF8String);
linphone_chat_room_send_chat_message(room, msg);
linphone_chat_room_mark_as_read(room);
}
}
}

View file

@ -911,6 +911,10 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, const char
NSString *callID = [NSString stringWithUTF8String:linphone_chat_message_get_custom_header(msg, "Call-ID")];
const LinphoneAddress *remoteAddress = linphone_chat_message_get_from_address(msg);
NSString *from = [FastAddressBook displayNameForAddress:remoteAddress];
const char *chat = linphone_chat_message_get_text(msg);
if (chat == NULL)
chat = "";
char *c_address = linphone_address_as_string_uri_only(remoteAddress);
NSString *remote_uri = [NSString stringWithUTF8String:c_address];

View file

@ -19,6 +19,7 @@
#import "SettingsView.h"
#import "LinphoneManager.h"
#import "LinphoneAppDelegate.h"
#import "PhoneMainView.h"
#import "Utils.h"
@ -432,6 +433,11 @@ static UICompositeViewDescription *compositeDescription = nil;
removeFromHiddenKeys = [video_preset isEqualToString:@"custom"];
[keys addObject:@"video_preferred_fps_preference"];
[keys addObject:@"download_bandwidth_preference"];
} else if ([notif.object isEqualToString:@"show_msg_in_notif"]) {
// we have to register again to the iOS notification, because we change the actions associated with IM_MSG
UIApplication *app = [UIApplication sharedApplication];
LinphoneAppDelegate *delegate = (LinphoneAppDelegate *)app.delegate;
[delegate registerForNotifications:app];
}
for (NSString *key in keys) {

View file

@ -102,6 +102,16 @@
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
</dict>
<dict>
<key>DefaultValue</key>
<true/>
<key>Key</key>
<string>show_msg_in_notif</string>
<key>Title</key>
<string>Show message in notification</string>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
</dict>
<dict>
<key>DefaultValue</key>
<true/>

View file

@ -14,3 +14,4 @@
"Username" = "Username";
"File sharing" = "File sharing";
"Server URL" = "Server URL";
"Show message in notification" = "Show message in notification";