title: How to Get Device Token in didFinishLaunchingWithOptions
body: <p>I am calling device token in my first <code>viewcontroller</code>. And I cant get result because Device token is null. Here below is my code in <code>appdelegate</code>:</p>
  
  <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  {
      [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge];
  
      return YES;
  }
  - (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
  {
      token = [[deviceToken description] stringByTrimmingCharactersInSet:      [NSCharacterSet characterSetWithCharactersInString:@"&lt;&gt;"]];
      token = [token stringByReplacingOccurrencesOfString:@" " withString:@""];
      NSLog(@"Device Token ---%@", token);
      [[NSUserDefaults standardUserDefaults] setObject:token forKey:@"DeviceToken"];
      [[NSUserDefaults standardUserDefaults] synchronize];
  }
  </code></pre>
  
  <p>When I am calling in Viewcontroller :</p>
  
  <pre><code>NSString *token=  [[NSUserDefaults standardUserDefaults] objectForKey:@"DeviceToken"];
  </code></pre>
  
  <p>token is null.</p>