mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 19:18:06 +00:00
improve push notification support
This commit is contained in:
parent
bab0498d4a
commit
a3ebd8f7d2
7 changed files with 51 additions and 21 deletions
|
|
@ -207,11 +207,19 @@
|
|||
NSDictionary *alert = [aps objectForKey:@"alert"];
|
||||
if(alert != nil) {
|
||||
NSString *loc_key = [alert objectForKey:@"loc-key"];
|
||||
/*if we receive a remote notification, it is because our TCP background socket was no more working.
|
||||
As a result, break it and refresh registers in order to make sure to receive incoming INVITE or MESSAGE*/
|
||||
LinphoneCore *lc=[LinphoneManager getLc];
|
||||
linphone_core_set_network_reachable(lc,FALSE);
|
||||
linphone_core_set_network_reachable(lc,TRUE);
|
||||
if(loc_key != nil) {
|
||||
if([loc_key isEqualToString:@"IM_MSG"]) {
|
||||
[[LinphoneManager instance] addInhibitedEvent:kLinphoneTextReceivedSound];
|
||||
[[PhoneMainView instance] changeCurrentView:[ChatViewController compositeViewDescription]];
|
||||
}
|
||||
}else{
|
||||
//it's a call
|
||||
[[LinphoneManager instance] didReceiveRemoteNotification];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -380,7 +380,12 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
|
|||
}
|
||||
// NSLocalizedString(@"IC_MSG", nil); // Fake for genstrings
|
||||
// NSLocalizedString(@"IM_MSG", nil); // Fake for genstrings
|
||||
NSString *params = [NSString stringWithFormat:@"APN-TOK=%@;APN-MSG=IM_MSG;APN-CAL=IC_MSG;APN-CAL-SND=ring.caf;APN-MSG-SND=msg.caf", tokenString];
|
||||
#ifdef DEBUG
|
||||
#define APPMODE_SUFFIX @"dev"
|
||||
#else
|
||||
#define APPMODE_SUFFIX @"prod"
|
||||
#endif
|
||||
NSString *params = [NSString stringWithFormat:@"app-id=%@.%@;pn-type=apple;pn-tok=%@;pn-msg-str=IM_MSG;pn-call-str=IC_MSG;pn-call-snd=ring.caf;pn-msg-snd=msg.caf", [[NSBundle mainBundle] bundleIdentifier],APPMODE_SUFFIX,tokenString];
|
||||
linphone_proxy_config_set_contact_parameters(proxyCfg, [params UTF8String]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ typedef struct _LinphoneManagerSounds {
|
|||
|
||||
@private
|
||||
NSTimer* mIterateTimer;
|
||||
|
||||
time_t lastRemoteNotificationTime;
|
||||
Connectivity connectivity;
|
||||
|
||||
NSMutableArray *inhibitedEvent;
|
||||
|
|
@ -101,6 +101,8 @@ typedef struct _LinphoneManagerSounds {
|
|||
- (BOOL)resignActive;
|
||||
- (void)becomeActive;
|
||||
- (BOOL)enterBackgroundMode;
|
||||
- (void)didReceiveRemoteNotification;
|
||||
- (BOOL)shouldAutoAcceptCall;
|
||||
|
||||
+ (void)kickOffNetworkConnection;
|
||||
- (void)setupNetworkReachabilityCallback;
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ struct codec_name_pref_table codec_pref_table[]={
|
|||
+ (NSSet *)unsupportedCodecs {
|
||||
NSMutableSet *set = [NSMutableSet set];
|
||||
for(int i=0;codec_pref_table[i].name!=NULL;++i) {
|
||||
if(linphone_core_find_payload_type([LinphoneManager getLc],codec_pref_table[i].name, codec_pref_table[i].rate) == NULL) {
|
||||
if(linphone_core_find_payload_type([LinphoneManager getLc],codec_pref_table[i].name, codec_pref_table[i].rate,-1) == NULL) {
|
||||
[set addObject:codec_pref_table[i].prefname];
|
||||
}
|
||||
}
|
||||
|
|
@ -205,6 +205,7 @@ struct codec_name_pref_table codec_pref_table[]={
|
|||
self.defaultExpires = 600;
|
||||
[self openDatabase];
|
||||
[self copyDefaultSettings];
|
||||
lastRemoteNotificationTime=0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
@ -663,7 +664,7 @@ static LinphoneCoreVTable linphonec_vtable = {
|
|||
ms_set_cpu_count(cpucount);
|
||||
|
||||
if (![LinphoneManager isNotIphone3G]){
|
||||
PayloadType *pt=linphone_core_find_payload_type(theLinphoneCore,"SILK",24000);
|
||||
PayloadType *pt=linphone_core_find_payload_type(theLinphoneCore,"SILK",24000,-1);
|
||||
if (pt) {
|
||||
linphone_core_enable_payload_type(theLinphoneCore,pt,FALSE);
|
||||
[LinphoneLogger logc:LinphoneLoggerWarning format:"SILK/24000 and video disabled on old iPhone 3G"];
|
||||
|
|
@ -713,6 +714,14 @@ static LinphoneCoreVTable linphonec_vtable = {
|
|||
}
|
||||
}
|
||||
|
||||
- (void)didReceiveRemoteNotification{
|
||||
lastRemoteNotificationTime=time(NULL);
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutoAcceptCall{
|
||||
return lastRemoteNotificationTime!=0 && lastRemoteNotificationTime-time(NULL)<10;
|
||||
}
|
||||
|
||||
- (BOOL)resignActive {
|
||||
if ([[LinphoneManager instance] settingsStore] != Nil)
|
||||
[[[LinphoneManager instance] settingsStore] synchronize];
|
||||
|
|
|
|||
|
|
@ -633,24 +633,30 @@ static PhoneMainView* phoneMainViewInstance=nil;
|
|||
if(address == nil) {
|
||||
address = @"Unknown";
|
||||
}
|
||||
|
||||
// Create a new notification
|
||||
appData->notification = [[UILocalNotification alloc] init];
|
||||
if (appData->notification) {
|
||||
appData->notification.repeatInterval = 0;
|
||||
appData->notification.alertBody =[NSString stringWithFormat:NSLocalizedString(@"IC_MSG",nil), address];
|
||||
appData->notification.alertAction = NSLocalizedString(@"Answer", nil);
|
||||
appData->notification.soundName = @"ring.caf";
|
||||
appData->notification.userInfo = [NSDictionary dictionaryWithObject:[NSData dataWithBytes:&call length:sizeof(call)] forKey:@"call"];
|
||||
if (![[LinphoneManager instance] shouldAutoAcceptCall]){
|
||||
// case where a remote notification is already received
|
||||
// Create a new local notification
|
||||
appData->notification = [[UILocalNotification alloc] init];
|
||||
if (appData->notification) {
|
||||
appData->notification.repeatInterval = 0;
|
||||
appData->notification.alertBody =[NSString stringWithFormat:NSLocalizedString(@"IC_MSG",nil), address];
|
||||
appData->notification.alertAction = NSLocalizedString(@"Answer", nil);
|
||||
appData->notification.soundName = @"ring.caf";
|
||||
appData->notification.userInfo = [NSDictionary dictionaryWithObject:[NSData dataWithBytes:&call length:sizeof(call)] forKey:@"call"];
|
||||
|
||||
[[UIApplication sharedApplication] presentLocalNotificationNow:appData->notification];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IncomingCallViewController *controller = DYNAMIC_CAST([self changeCurrentView:[IncomingCallViewController compositeViewDescription] push:TRUE],IncomingCallViewController);
|
||||
if(controller != nil) {
|
||||
[controller setCall:call];
|
||||
[controller setDelegate:self];
|
||||
}
|
||||
if ([[LinphoneManager instance] shouldAutoAcceptCall]){
|
||||
linphone_core_accept_call(linphone_call_get_core(call),call);
|
||||
}else{
|
||||
IncomingCallViewController *controller = DYNAMIC_CAST([self changeCurrentView:[IncomingCallViewController compositeViewDescription] push:TRUE],IncomingCallViewController);
|
||||
if(controller != nil) {
|
||||
[controller setCall:call];
|
||||
[controller setDelegate:self];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
2
submodules/externals/exosip
vendored
2
submodules/externals/exosip
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit dfe434328c0b0cbbaee669d40b27e09fea5f49ab
|
||||
Subproject commit 6ba04c22ccc8b140a9de84124d0e4ee7a406705b
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 199108c92435cc0f7daf3dd8f6bdc6d9830b3af0
|
||||
Subproject commit bd6a9737485893b0bc08ffe75dfea6f71115b73c
|
||||
Loading…
Add table
Reference in a new issue