diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 8f9d523d3..d9c68a97d 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -172,24 +172,29 @@ UIApplication* app= [UIApplication sharedApplication]; UIApplicationState state = app.applicationState; - - if( [app respondsToSelector:@selector(registerUserNotificationSettings:)] ){ - /* iOS8 notifications can be actioned! Awesome: */ - UIUserNotificationType notifTypes = UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert; - - NSSet* categories = [NSSet setWithObjects:[self getCallNotificationCategory], [self getMessageNotificationCategory], nil]; - UIUserNotificationSettings* userSettings = [UIUserNotificationSettings settingsForTypes:notifTypes categories:categories]; - [app registerUserNotificationSettings:userSettings]; - [app registerForRemoteNotifications]; - } else { - NSUInteger notifTypes = UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeNewsstandContentAvailability; - [app registerForRemoteNotificationTypes:notifTypes]; - } LinphoneManager* instance = [LinphoneManager instance]; BOOL background_mode = [instance lpConfigBoolForKey:@"backgroundmode_preference"]; BOOL start_at_boot = [instance lpConfigBoolForKey:@"start_at_boot_preference"]; - + + + if( !instance.isTesting ){ + if( [app respondsToSelector:@selector(registerUserNotificationSettings:)] ){ + /* iOS8 notifications can be actioned! Awesome: */ + UIUserNotificationType notifTypes = UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert; + + NSSet* categories = [NSSet setWithObjects:[self getCallNotificationCategory], [self getMessageNotificationCategory], nil]; + UIUserNotificationSettings* userSettings = [UIUserNotificationSettings settingsForTypes:notifTypes categories:categories]; + [app registerUserNotificationSettings:userSettings]; + [app registerForRemoteNotifications]; + } else { + NSUInteger notifTypes = UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeNewsstandContentAvailability; + [app registerForRemoteNotificationTypes:notifTypes]; + } + } else { + NSLog(@"No remote push for testing"); + } + if (state == UIApplicationStateBackground) { diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index 99adcdb7d..5bd91a667 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -180,6 +180,7 @@ typedef struct _LinphoneManagerSounds { - (BOOL)lpConfigBoolForKey:(NSString*)key forSection:(NSString*)section; - (void)silentPushFailed:(NSTimer*)timer; +@property (readonly) BOOL isTesting; @property (readonly) FastAddressBook* fastAddressBook; @property Connectivity connectivity; @property (readonly) NetworkType network; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 3a08d0683..fccae1c7c 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -200,6 +200,12 @@ struct codec_name_pref_table codec_pref_table[]={ #endif } ++ (BOOL)isRunningTests { + NSDictionary *environment = [[NSProcessInfo processInfo] environment]; + NSString *injectBundle = environment[@"XCInjectBundle"]; + return [[injectBundle pathExtension] isEqualToString:@"xctest"]; +} + + (BOOL)isNotIphone3G { static BOOL done=FALSE; @@ -278,6 +284,7 @@ struct codec_name_pref_table codec_pref_table[]={ [self copyDefaultSettings]; pushCallIDs = [[NSMutableArray alloc] init ]; photoLibrary = [[ALAssetsLibrary alloc] init]; + self->_isTesting = [LinphoneManager isRunningTests]; NSString* factoryConfig = [LinphoneManager bundleFile:[LinphoneManager runningOnIpad]?@"linphonerc-factory~ipad":@"linphonerc-factory"]; NSString *confiFileName = [LinphoneManager documentFile:@".linphonerc"]; diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m index 2d220f2ad..bf240e618 100644 --- a/Classes/PhoneMainView.m +++ b/Classes/PhoneMainView.m @@ -407,15 +407,17 @@ static RootViewManager* rootViewManagerInstance = nil; LinphoneCore* core = nil; @try { core = [LinphoneManager getLc]; + LinphoneManager* lm = [LinphoneManager instance]; if( linphone_core_get_global_state(core) != LinphoneGlobalOn ){ [self changeCurrentView: [DialerViewController compositeViewDescription]]; } else if ([[LinphoneManager instance] lpConfigBoolForKey:@"enable_first_login_view_preference"] == true) { // Change to fist login view [self changeCurrentView: [FirstLoginViewController compositeViewDescription]]; } else { + // always start to dialer when testing // Change to default view const MSList *list = linphone_core_get_proxy_config_list(core); - if(list != NULL || ([[LinphoneManager instance] lpConfigBoolForKey:@"hide_wizard_preference"] == true)) { + if(list != NULL || ([lm lpConfigBoolForKey:@"hide_wizard_preference"] == true) || lm.isTesting) { [self changeCurrentView: [DialerViewController compositeViewDescription]]; } else { WizardViewController *controller = DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[WizardViewController compositeViewDescription]], WizardViewController);