Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7526211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:46:25+00:00 2026-05-30T03:46:25+00:00

in my app I use push notifications and it seems to me that the

  • 0

in my app I use push notifications and it seems to me that the request to register for push takes a while, which stops my app from immediatly displaying content and only showing a black screen until the device token comes back.

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    ....

    NSLog(@"Registering for push notifications...");    
    [[UIApplication sharedApplication] 
     registerForRemoteNotificationTypes:
     (UIRemoteNotificationTypeAlert | 
      UIRemoteNotificationTypeBadge | 
      UIRemoteNotificationTypeSound)];

    ....

    return self;
}

How can I do this asynchrounus or in the background.. because it confuses users if the screen stays black…

regards

UPDATE: as requested my code

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    self.webViewCon = [[[WebViewController alloc] initWithNibName:@"WebView_iPhone" bundle:[NSBundle mainBundle]] autorelease];

    application.applicationIconBadgeNumber = 0;
    [window addSubview:[webViewCon view]];
    [self.window makeKeyAndVisible];

    // register for push
    NSLog(@"Registering for push notifications...");    
   [[UIApplication sharedApplication] 
     registerForRemoteNotificationTypes:
     (UIRemoteNotificationTypeAlert | 
      UIRemoteNotificationTypeBadge | 
      UIRemoteNotificationTypeSound)];

    return YES;
}

And then in didRegisterForRemoteNotificationsWithDeviceToken

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    NSString *str = [NSString stringWithFormat:@"Device Token=%@",deviceToken];
    NSLog(@"%@",str);

    // get token & udidi
    NSString* newToken = [deviceToken description];
    newToken = [newToken stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
    newToken = [newToken stringByReplacingOccurrencesOfString:@" " withString:@""]; 
    NSString *udid = [UIDevice currentDevice].uniqueIdentifier;

    // send request to server to save token
    NSString *urlString = [NSString stringWithFormat:@"https://my.server.com/service/token?token=%@&udid=%@",newToken, udid];

    NSURL *url = [[NSURL alloc] initWithString:urlString];

    NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
    [url release];

    NSURLResponse *response;
    [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:nil];
}

and in my WebViewController.m

- (void)viewDidLoad
{
    // create and send POST request
    NSURL *url = [NSURL URLWithString:myUrlAddress];
    NSString *udid = [UIDevice currentDevice].uniqueIdentifier;
    NSString *requestString = [NSString stringWithFormat:@"udid=%@", udid];
    NSData *requestData = [NSData dataWithBytes: [requestString UTF8String] length: [requestString length]];
    NSMutableURLRequest *requestObj = [[NSMutableURLRequest alloc] initWithURL:url];
    [requestObj setHTTPMethod:@"POST"];
    [requestObj setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
    [requestObj setHTTPBody: requestData];
    NSURLResponse *response;
    NSError *err;
    [NSURLConnection sendSynchronousRequest: requestObj returningResponse:&response error:&err];

    // set delegate
    webView.delegate = self;

    // set backgroundcolor
    [webView setOpaque:NO];
    [webView setBackgroundColor:RGB(154, 148, 131)];

    // check internet and load
    NetworkStatus currentStatus = [[Reachability reachabilityForInternetConnection] 
                               currentReachabilityStatus];
    if(currentStatus != NotReachable) {
        //Load the request in the UIWebView.
        [webView loadRequest:requestObj];
    }
    else {
        UIAlertView *alert = [[UIAlertView alloc]
                          initWithTitle:@"No Connection" 
                          message:@"Check your Wi-Fi connection and restart the App." 
                          delegate:self
                          cancelButtonTitle:nil 
                          otherButtonTitles:@"Ok", nil];
        [alert show];
        [alert release];
    }
    // prevent scrolling up & down
    [[[webView subviews] lastObject] setScrollEnabled:NO];

   [super viewDidLoad];
}

hope that helps… could Reachabilit also be the problem?

Kind Regards for reading

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:46:26+00:00Added an answer on May 30, 2026 at 3:46 am

    According developer.apple.com, registerForRemoteNotificationTypes IS asynchronous:

    When you send this message, the device initiates the registration process with Apple Push Service. If it succeeds, the application delegate receives a device token in the application:didRegisterForRemoteNotificationsWithDeviceToken: method; if registration doesn’t succeed, the delegate is informed via the application:didFailToRegisterForRemoteNotificationsWithError: method.

    May be you do smth time consuming in callbacks of delegate?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I submit a newstand app that does not use push notifications, but instead
I am working on an android app that will recieve push notifications from the
I am making my first app which will use push notifications. I have decided
I want to use push notification in my app.i want to know that do
My app was configured to use push notifications and was working fine. My certificate
I have an app that currently uses C2DM for push notifications. I would like
I'm building an iOS app that uses push notifications, and I'm finally ready to
I am using Web2Py to create a simple app which sends Push notifications through
I have created an app which using APNS. I have got the push notifications
I would like to use push notification (available from 2.2 onwards) for my app.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.