运行视图控制器代码之前,我有这个代码的和平得到设备ID:获取设备ID在IOS
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSString *devicetokenRN = [NSString stringWithFormat:@"%@", deviceToken];
devicetokenRN = [devicetokenRN stringByReplacingOccurrencesOfString:@" " withString:@""];
devicetokenRN = [devicetokenRN stringByReplacingOccurrencesOfString:@"<" withString:@""];
devicetokenRN = [devicetokenRN stringByReplacingOccurrencesOfString:@">" withString:@""];
// send device token for APNS without spaces or <>
DeviceID *DeviceIdentifier = [[DeviceID alloc ] init];
// sending it to the Device.h
[DeviceIdentifier setDeviceID:devicetokenRN];
}
我需要检索此的DeviceID作为我的ViewController的第一件事。由于它运行的视图控制器之前,因为如果我在ViewController中使用的NSLog它是NULL,因为它并没有执行这个第一它没有做这个功能。在运行UITableView之前,我需要先获得一些像这样的变量。任何想法将是非常感谢。
的registerForRemoteNotificationTypes方法执行fromdidFinishLaunchingWithOptions,这是我可以,谢谢运行它最早的地方。 – user3328028