title: Waiting for service operation in didFinishLaunchingWithOptions AND didRegisterForRemoteNotificationsWithDeviceToken called after delay
body: <p>I am not sure where exactly my question fit. Here is the issue :<br>
  I want the push notifications to be registered on application start. For which I am registering in <strong>AppDelegate</strong> <code>didFinishLaunchingWithOptions</code>.  </p>
  
  <pre><code>sem = dispatch_semaphore_create(0);
  [manager registerForPushNotifications];
  dispatch_semaphore_signal(sem);
  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER); 
  </code></pre>
  
  <p>If I don't use <code>GCD</code>, <code>return YES;</code> of <code>didFinishLaunchingWithOptions</code> is called first and in that case, my my service method, which want to call from <code>didRegisterForRemoteNotificationsWithDeviceToken</code> for sending device token is not called.   </p>
  
  <pre><code>// system push notification registration success callback, delegate to pushManager
  - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
      NSString *token = [[deviceToken description] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"&lt;&gt;"]];
      token = [token stringByReplacingOccurrencesOfString:@" " withString:@""];
      NSLog(@"content---%@", token);
      [[NSUserDefaults standardUserDefaults]setObject:token forKey:@"deviceToken"];
      [self registerForPushWooshNotification];
      [[PushNotificationManager pushManager] handlePushRegistration:deviceToken];
  }  
  
  -(void)registerForPushWooshNotification
  {
      NSDictionary *params = @{@"TokenId": [[NSUserDefaults standardUserDefaults]objectForKey:@"deviceToken"]
                               };
  
      [_sharedHandler.requestManager POST:TGURL_PUSHWOOSH_NOTIFICATION
                               parameters:params
                                  success:^(AFHTTPRequestOperation *operation, id responseObject) {
  
                                      NSError *e;
                                      NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:[operation.responseString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&amp;e];
                                      NSLog(@"------ Registered for Pushwoosh ------");
                                  }
                                  failure:^(AFHTTPRequestOperation *operation, NSError *error) {
  
                                  }];
  }  
  </code></pre>
  
  <p>But as I have implemented the <code>GCD</code>, <code>didRegisterForRemoteNotificationsWithDeviceToken</code> never gets called.  </p>
  
  <p><strong>Summary</strong> :  </p>
  
  <p><strong>1. I have to register application on app start.<br>
  2. Web Service needs to be called on app start.<br>
  3. If GCD not used : return YES; is called first, and didRegisterForRemoteNotificationsWithDeviceToken gets called after delay.<br>
  4. If GCD used : didRegisterForRemoteNotificationsWithDeviceToken is never called.</strong>    </p>
  
  <p>I had searched for <a href="https://www.google.co.in/?gfe_rd=cr&amp;ei=m9-4VLLzOIrC8geSzoGgBA&amp;gws_rd=ssl#q=didfinishlaunchingwithoptions+wait" rel="nofollow"><strong>didFinishLaunchingWithOptions wait</strong></a> and <a href="https://www.google.co.in/?gfe_rd=cr&amp;ei=m9-4VLLzOIrC8geSzoGgBA&amp;gws_rd=ssl#q=didRegisterForRemoteNotificationsWithDeviceToken+called+after+delay" rel="nofollow"><strong>didRegisterForRemoteNotificationsWithDeviceToken called after delay</strong></a> on google before posting this question but no success.</p>