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

  • Home
  • SEARCH
  • 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 6896903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:06:08+00:00 2026-05-27T07:06:08+00:00

Im using the push notification service in my app. But it is now always

  • 0

Im using the push notification service in my app.

But it is now always showing(when app launches) that it is failed to register for pushnotification.

i used the below code for push notifications:

Can anyone help me where i’m going wrong.

Thanks in advance.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    if(application.applicationIconBadgeNumber != 0){
        [[[[[self tabBarController] viewControllers] objectAtIndex: 1] tabBarItem] setBadgeValue:@"new"];}




     [self.window addSubview:tabBarController.view];
     [self.window makeKeyAndVisible];
     NSLog(@"Registering for push notifications...");    
     [[UIApplication sharedApplication] 
     registerForRemoteNotificationTypes:
     (UIRemoteNotificationTypeAlert | 
      UIRemoteNotificationTypeBadge | 
      UIRemoteNotificationTypeSound)];
        return YES;

}


- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { 
    NSLog(@"asdfasdf");

    NSString *str = [NSString 
                     stringWithFormat:@"Device Token=%@",deviceToken];

        const char* data = [deviceToken bytes];
    NSMutableString* token = [NSMutableString string];

    for (int i = 0; i < [deviceToken length]; i++) {
        [token appendFormat:@"%02.2hhX", data[i]];
    }

    NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"http://chargrilled.k-hosting.co.uk/test2/register_device.php?dt=%@",token]];
    NSMutableURLRequest* request = [[[NSMutableURLRequest alloc] initWithURL:url]autorelease];
    NSURLConnection* connection = [NSURLConnection connectionWithRequest:request delegate:self];


    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Device registered for push notification."
                                                 message:nil
                                                delegate:self
                                       cancelButtonTitle:nil
                                       otherButtonTitles:@"Okay", nil];
    [alert show];
    [alert release];



}
- (NSString*)stringWithDeviceToken:(NSData*)deviceToken {


}


- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err { 
    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Device registration failed."
                                                 message:nil
                                                delegate:self
                                       cancelButtonTitle:nil
                                       otherButtonTitles:@"Okay", nil];
    [alert show];
    [alert release];

}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    int i;

    for (id key in userInfo) {
        i++;
        NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
        if(i==2){

        }
    }

    application.applicationIconBadgeNumber = [[userInfo objectForKey:@"badge"] integerValue];
    [[[[[self tabBarController] viewControllers] objectAtIndex: 1] tabBarItem] setBadgeValue:@"new"];


}
  • 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-27T07:06:09+00:00Added an answer on May 27, 2026 at 7:06 am

    Check the profile u are using, is it enable for push notification. If not create a new with push notification.

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

Sidebar

Related Questions

I have an iOS app using push notification but once in a while I'm
Thanks in advance. I used push notification service in my application.If the app is
I have implemented a sample push notification service for my App. Right now I
I have implemented Apple Push Notification service using Urban Airship and successfully received the
I have implemented whole push notification service for my application using easyapns . I
I am creating an application with push notification alerts using Google C2DM service. Can
My app is using Google's C2DM (push notification) to notify users about new activity
while i'm using push notification in iphone with local server(used php), not able to
I am using the Microsoft Push Notification Service to send push notifications, and i
I am trying to use the push notification service provided by apple but I

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.