我有一个使用推送通知的代码,但我想开始调试我的代码的一些功能,并希望在模拟器中运行,我的问题是
如何告诉xcode忽略didregisterForRemote ....
我可以在此基础上评论和发挥什么?
任何帮助将不胜感激
谢谢
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {
NSString *device_token =[[[[deviceToken description] stringByReplacingOccurrencesOfString:@"<"withString:@""]
stringByReplacingOccurrencesOfString:@">" withString:@""]
stringByReplacingOccurrencesOfString: @" " withString: @""];
[self checkUUID];
Authentication *auth = [[Authentication alloc] initWithObject];
int erro = [auth insertDeviceInfo:device_token];
UINavigationController *navigationController = [self customizedNavigationController];
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.viewController.erro = erro;
[navigationController setViewControllers: [NSArray arrayWithObject: self.viewController]];
[self setNavigationController:navigationController];
[self.window setRootViewController: navigationController];
[self.window makeKeyAndVisible];
}
我只是希望能够使用模拟器来移动我的调试
答案 0 :(得分:3)
最好的方法是使用宏TARGET_IPHONE_SIMULATOR
#if !(TARGET_IPHONE_SIMULATOR)
NSLog(@"this is only real device code");
#endif
答案 1 :(得分:0)
如果您想使用编码实现该目标,请在
中使用以下条件didRegisterForRemoteNotificationsWithDeviceToken:
在模拟器上忽略此类功能的方法:
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
if ([model isEqualToString:@"iPhone Simulator"]) { //device is simulator } else { //Actual Device }
}