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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:45:52+00:00 2026-06-02T17:45:52+00:00

Am integrating APNS in my iPhone app. I have walked through on Apple Push

  • 0

Am integrating APNS in my iPhone app. I have walked through on Apple Push Notification document provided from Apple. I have a doubt on server side. Please find my doubts below,

  1. Apple said to create a server from below steps,

    Installing the SSL Certificate and Key on the Server:
    You should install the SSL distribution certificate and private cryptographic key you obtained earlier on the server computer on which the provider code runs and from which it connects with the sandbox or production versions of APNs. To do so, complete the following steps:
    1.1.Open Keychain Access utility and click the My Certificates category in the left pane.
    1.2.Find the certificate you want to install and disclose its contents.
    You'll see both a certificate and a private key.
    1.3.Select both the certificate and key, choose File > Export Items, and export them as a Personal Information Exchange (.p12) file.
    1.4.Servers implemented in languages such as Ruby and Perl often are better able to deal with certificates in the Personal Information Exchange format. To convert the certificate to this format, complete the following steps:
         a.In KeyChain Access, select the certificate and choose File > Export Items. Select the Personal Information Exchange (.p12) option, select a save location, and click Save.
         b.Launch the Terminal application and enter the following command after the prompt: openssl pkcs12 -in CertificateName.p12 -out CertificateName.pem -nodes
    1.5.Copy the .pem certificate to the new computer and install it in the appropriate place.

Am clear to create a server (i assume it will be .php server). Am doubt is how we storing all user's DeviceTokens in the server?

2. How to send push notifications to all registered devicetokens?
3. How to send push notifications to a specific user?

Can you please give some suggestion regarding my questions? I got a sample .php file from this link http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12. Please help me. Thanks in advance.

  • 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-02T17:45:52+00:00Added an answer on June 2, 2026 at 5:45 pm

    You can get it on serverside with this code:

    -(void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
    {
    NSLog(@"My token is: %@", deviceToken);
    
    
        NSData *postData = [[NSString stringWithFormat:@"token=%@", deviceToken] dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
    
        NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];
    
        NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
        [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"YOURDOMAIN/FILE.php"]]];
    
        [request setHTTPMethod:@"POST"];
    
        [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
    
        [request setHTTPBody:postData];
    
        NSURLConnection *conn = [[NSURLConnection alloc]initWithRequest:request delegate:self];
    }
    

    Just store your tokens in DB ($_POST[‘token’])

    To send notifications you have to do a loop which looks like this:

    //getTokens from database
    $deviceToken = getDeviceTokens();
    
    foreach($arr AS $key => $val)
        {
            // Create the payload body
            $body['aps'] = array(
                    'alert' => 'Puuuuush',
                    'sound' => 'vuvzela.wav',
                    'badge' => ($badge != (null) ? $badge + 1 : 1)
                    );
    
    // Encode the payload as JSON
            $payload = json_encode($body);
    
            // Build the binary notification
            $msg = chr(0) . pack('n', 32) . pack('H*', $val) . pack('n', strlen($payload)) . $payload;
    
            // Send it to the server
            $result = fwrite($fp, $msg, strlen($msg));
    
            if (!$result)
                    echo 'Message not delivered' . PHP_EOL;
            else
                    echo 'Message successfully delivered' . PHP_EOL;
    
            $count++;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am integrating a Push Provider Server with the codes (php-apns) from google codes.
I'm integrating redis into my NodeJS server app, and I'm trying to figure out
I am integrating with a webservice who have provided a wsdl file to access
We're integrating a library into an iPhone app which appears to use the google
Im integrating local notification into my app. It is working fine. But client want
I am integrating Klazuka Kal into my iPhone app and need more space to
While integrating a Django app I have not used before, I found two different
Integrating 2 systems, we need to insert records from mysql to sql-server: MYSQL SQLServer
I am integrating my app with FaceBook on iPhone. When the first time user
I am integrating the MailChimp API into my app and am using a UserObserver

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.