jeudi 29 janvier 2015

xCode loses connection to device when running app

I have been building an iOS app and have been testing it both on the simulator as well as my iPad. Everything was working perfectly until-

when i recently added the code to register for push notifications to my AppDelegate.m file. Now when I try to run the app on the device the app lingers on the splash screen for a while and then xCode comes up with the following error.



process launch failed: timed out waiting for app to launch



and here's the code i added, Just in case :



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
if ([[UIApplication sharedApplication]respondsToSelector:@selector(registerUserNotificationSettings:)])
{
UIUserNotificationType userNTypes = (UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound);

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNTypes categories:nil];

NSLog(@"sherikkum registering 8.xx...");

[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}
#else
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

#endif

return YES;
}

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
NSLog(@"My token is: %@", deviceToken);

//I added this alert coz i couldnt view NSLogs - coz my xcode wont connect
UIAlertView *tokenalert = [[UIAlertView alloc] initWithTitle:@"Token"
message:[NSString stringWithFormat:@"%@",deviceToken]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[tokenalert show];
}

- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
NSLog(@"Failed to get token, error: %@", error);
}


Thanks




Aucun commentaire:

Enregistrer un commentaire