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 8162943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:54:01+00:00 2026-06-06T18:54:01+00:00

I am using the APNS for receiving push notifications in my application. The problem

  • 0

I am using the APNS for receiving push notifications in my application.

The problem is that I am getting the same notifications on some devices but not all. What could the problem be here since I have been trying for about 15 days to solve this issue with no success. Th device token is updating successfully. Because had it not been then I wouldn’t have been getting notification on any device. But the strange thing is I am getting it on half the devices. Please help!!

Here is the code for registering and receiving notifications. I don’t have any code for server side. But as I said that the notifications are working on some devices. On android too they are working.

I have 3 devices here with me and its working on two of them.
iPad2:5.0.1
iPodTouch:4.3.3

Its not working on another iPod touch that I have on version:5.1

Also its showing successfully registered for APNS in all devices. But not sending notifications on some. What can the issue be? Is there something that I am missing?

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken 
{

    deviceToken = [devToken retain];

    NSLog(@"Registered for APNS %@", deviceToken);

    NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];

    NSMutableString *dev = [[NSMutableString alloc] init];

    NSRange r;
    r.length = 1;
    unsigned char c;

    for (int i = 0; i < [deviceToken length]; i++)
    {
        r.location = i;
        [deviceToken getBytes:&c range:r];

        if (c < 10) {
            [dev appendFormat:@"0%x", c];
        }
        else {
            [dev appendFormat:@"%x", c];
        }

    }

    [ud setObject:dev forKey:@"DeviceToken"];
    [ud synchronize];

}

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error 
{

    NSLog(@"Failed to register %@", [error localizedDescription]);

    deviceToken = nil;

}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
for(int i=0;i<[viewControllers count];i++)
        {
            if([[viewControllers objectAtIndex:i] isKindOfClass:[Confirmation class]])
            {
                Confirmation *map = (Confirmation*)[[self.navigationController viewControllers] objectAtIndex:i];
                [map setFinalInfo];
                [self.navigationController popToViewController:[[self.navigationController viewControllers] objectAtIndex:i] animated:YES];
            }
        }
}
  • 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-06-06T18:54:02+00:00Added an answer on June 6, 2026 at 6:54 pm

    I replaced the following code:

    deviceToken = [devToken retain];
    
        NSLog(@"Registered for APNS %@", deviceToken);
    
        NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
    
        NSMutableString *dev = [[NSMutableString alloc] init];
    
        NSRange r;
        r.length = 1;
        unsigned char c;
    
        for (int i = 0; i < [deviceToken length]; i++)
        {
            r.location = i;
            [deviceToken getBytes:&c range:r];
    
            if (c < 10) {
                [dev appendFormat:@"0%x", c];
            }
            else {
                [dev appendFormat:@"%x", c];
            }
    
        }
    
        [ud setObject:dev forKey:@"DeviceToken"];
        [ud synchronize];
    

    By this:

    [devToken retain];
        NSLog(@"~~~~devToken=%@",devToken); 
        NSString *dt = [[devToken description] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"<>"]]; 
        dt = [dt stringByReplacingOccurrencesOfString:@" " withString:@""]; 
        //     //DeviceToken = dt;
        NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
        [def setObject:dt forKey:@"DeviceToken"];
        [def synchronize];
    

    and its working fine now!!

    The problem was it wasnt updating the device toekn correctly for some devices which I am not sure why as it was working well for some.

    Thanks guys!!

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

Sidebar

Related Questions

I have been using https://github.com/Redth/APNS-Sharp to send push notification message to all devices where
I have an app that is using push notifications with apples APNS. Most of
Currently I am using APNS PHP for push notification. The problem is I can't
I am working on one application that has APNS in the same. And for
I am using PHP to connect to apns to send some notifications to multiple
I want to send push notifications to iPhones using c#. I currently use apns-sharp
I implemented push notifications using APNS-PHP http://code.google.com/p/apns-php/ on my server. I now have to
I have created an app which using APNS. I have got the push notifications
I am using APNS service in my universal app (iPhone/iPad) and i am not
I am trying to make a chatting application, text chatting using APNS and in

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.