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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:29:49+00:00 2026-05-28T05:29:49+00:00

I know it’s a little bit flooded with Apple’s Push Notification Service (APNs) issues

  • 0

I know it’s a little bit flooded with Apple’s Push Notification Service (APNs) issues all over StackOverflow so I actually did a lot of researches before coming up my question.

Basically, I have followed the apns-php’s CertificateCreation, some tutorial like on mobiforge, and some from Matthijs Hollemans. Still, I can’t get any notification posted onto my iPad 2.

Basically these are the steps I have done:

  1. I followed the CertificateCreation tutorial, I came out with server_certificates_bundle_sandbox.pem, entrust_root_certification_authority.pem.
  2. Followed the tutorial specified in mobiforge blog, I successfully created the App ID, provisioning profile and linked them together nicely.

    • Description: APNTest
    • Bundle Seed ID: Use Team ID
    • Bundle Identifier: com.learn.APN
  3. Then I enable the Development Push SSL Certificate (only for now) using the same certificate request I have used just now to get the certs, and I download it and install it into my keychain.

  4. I downloaded my provisioning profile in .mobileprovision file and loaded it into Xcode’s Organizer under my iPad 2 device.

  5. Next I create a simple application with only these codes:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
        // Override point for customization after application launch.
        return YES;
    }
    
    - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
    {
        NSLog(@"%@", deviceToken);
    }
    
    - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
    {
        NSLog(@"Error: %@", error);
    }
    
  6. Then I configure the build parameters:

    • Targets > Info > Build Identifier: net.learn.APN
    • Targets > Build Settings > Code Signing Identity > (I chose the provisioning profile I have installed just now, and it automatically selects the identical profiles for my Debug and Release)
  7. I build and run the application on my iPad 2. My application requesting for Push Notification and after I approved it, the Token ID appeared in my console:

    2012-01-19 12:43:26.345 TestAPN[578:707] <3cb08612 9392996b 5332d2fc 5adce03d 994f8959 d7a2ac38 de7bed52 c8e0778e>
    
  8. I used apns-php, changed the device ID (raw 64 hexa-values), then run the sample_push.php. Script ran successfully, but my device is not receiving any notification

  9. Then I try to use the SimplePush.php. A “Message successfully delivered” appeared, but my iPad still doesn’t receive any notification from APN

Question is, which steps have I done wrongly? I’m pretty newbie in this area, and it is actually a requirement for my project that the server need to send out messages to our own applications. We are aware of the third party softwares that send APN on behalf of you, but we would like to implement one ourselves.

I also came across the “APN Feedback Service” and I written this (base on the SimplePush) but sadly it’s empty. What should I do now?

<?php
// Put your private key's passphrase here:
$passphrase = '';

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'server_certificates_bundle_sandbox.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);

// Open a connection to the APNS server
$fp = stream_socket_client(
        'ssl://feedback.sandbox.push.apple.com:2196', $err,
        $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);

if (!$fp)
        exit("Failed to connect: $err $errstr" . PHP_EOL);

echo 'Connected to APNS' . PHP_EOL;

while (!feof($fp)) {
        $data = fgets($fp, 1024);
        var_dump(unpack("N1timestamp/n1length/H*devtoken", $data));
}
// Close the connection to the server
fclose($fp);

Note

  1. I am aware of the differences between development/production certs.
  2. iPad is not jailbroken, running iOS 5.0.1
  3. Other App Store apps receives notifications normally
  4. XCode 4.2.1, Lion 10.7.2

I hope I’m not duplicates any of the questions here.. 😉

EDIT

When I run php simplepush.php then php feedback.php, I received a feedback with my device ID. My App is still in the iPad, so does it mean my device ID is wrong?

[root@ip-xx-xx-xx-xx SimplePush]# php feedback.php
Connected to APNS
array(3) {
  ["timestamp"]=>
  int(1326962028)
  ["length"]=>
  int(32)
  ["devtoken"]=>
  string(64) "3cb086129392996b5332d2fc5adce03d994f8959d7a2ac38de7bed52c8e0778e"
}

Thanks

EDIT

After much struggling and redoing all the steps written by Matthijs Hollemans, I finally get it working. So the problem lies within the incorrect PEM file generated… hmm

  • 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-28T05:29:49+00:00Added an answer on May 28, 2026 at 5:29 am

    I had similar problem, for me the key thing I didn’t know is that the device token is different for dev and prod (for the same device).

    I was using the device token I got when testing in dev to test in prod. This was working fine in dev, but when I switched to prod I kept the same device token in my python script (assuming, wrongfully, that the device token would be the same for the same device) but the actual device token registered in prod was different.

    In practice this wouldn’t happen as the device token is sent to the server, but when I was testing I was using hard coded device token as I didn’t want to involve the server.

    Hopefully this will save someone some frustration.

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

Sidebar

Related Questions

I know very little about Agile but I wonder if there is any difference
I know that in Rails all ActiveRecord callbacks are executed inside transaction. So if
I know the title isn't informative at all, but I had no idea how
I know the title is Very wide - spanning over a lot ! And
I know this question has been around, but I found answers a bit foggy,
I know that all of these will be compiled together into one file but
I know this question as been asked over and over but it's still quite
I know, there are several questions of this type but I tried all of
Know of an OCAML/CAML IDE? Especially one that runs on Linux?
Know of any good libraries for this? I did some searches and didn't come

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.