Tutorial: Apple Push Notifications with PhoneGap – Part 1

October 19, 2012By 30 Comments

This is part 1 of a new series to help explain how to set up and use Apple Push Notifications (APNs) in your mobile applications. Push notifications are different than local notifications in that they are coming from a 3rd party server to inform the user of something, versus a local notification which is scheduled by the application to run on the device itself without any server interaction. For instance you may receive a push notification from Facebook notifying you that someone has added you as a friend, or if you are a Words With Friends player you may receive a push notification indicating it’s your turn. An example of a local notification would be an alert popping up at a certain time or interval as a reminder from a to do application where you set a date/time to a task and the alert pops up to remind you at that specified time. To the end user they may appear the same in that they both pop alerts, can have sounds associated etc, but they are very different from a development perspective.

There are Cordova/PhoneGap plugins to do both local and push notifications for iOS, but this series will focus on push notifications. If you’re wondering about Android, there is a concept of push notifications but the setup and process is a bit different and will be covered in a later post.

The process to get started with setting up APNs can be a bit intimidating initially but it’s worth taking the time to do so as the use cases are endless. This series is intended to help you understand the whole process including setup and what is occurring on both the application and server-side with sample code to get you started quickly.

APN Workflow Overview

(credit to Ray Wenderlich)

(credit to Apple Inc)

Explanation of Workflow

  • Upon launch, your application communicates with the Apple Push Notification Service to authorize it to receive push notifications.
  • Apple responds with a unique token that must be used in all future communications to receive push notifications.
  • Your application sends that token to a 3rd party server (your own or some other provider like Urban Airship for instance), that will store it for later events when the application needs to be notified.
  • When an event occurs where your application needs to receive a notification, the server script reads in the unique device token and sends a message with a pre-defined structure to the Apple Push Notification Services which then securely sends to your device. The structure may include a message, sound and badge number to display on the application launch icon or any combination of the three.

High Level How-To (details to follow):

  1. iOS Provisioning Portal
    • Create a new App ID with push notifications enabled and an SSL Certificate associated
    • Create a new provisioning file for the above App ID and download it
    • Drag new provisioning file into XCode (or via XCode Organizer)
    • Associate new provisioning file with your Project in the Code Signing Options
  2. Cordova/PhoneGap Plugin Setup
    • Download Cordova Plugin for PushNotifications
    • Add PushNotification plugin key and value to Cordova.plist
    • Drag PushNotification folder to XCode Plugins Folder (create groups for any added folders) – only the PushNotification.m and PushNotification.h are needed here for the native, see next step for the PushNotification.js client side
    • In Finder, copy the PushNotification.js file from your downloaded plugin into the existing www folder
    • Add a script tag to refer to the new PushNotification.js
    • Add methods to the AppDelegate.m (under Classes) to handle push notification events and code for handling launch of application from a push notification
  3. Client Side Application Handling
    • Add code to register the user’s device
    • Add code to listen for notification events when app is active
    • Add code for badge management (clear on relaunch from notification etc)
    • Add code to check user’s notification status – which options do they have set for this application specifically (they can control notification type, badge/alert/sound)
    • Add code to get pending notifications (ie: if app is opened from the push notification, we need to access that notification to get the data passed in to see if updates are needed etc)
    • Include resources in your project for custom sounds or launch images to be associated with your push notification
  4. Server Side Handling (Optional)
    • Specify the URL to the Apple Push Notification Service gateway (sandbox or production)
    • Ensure proper certificates available on server
    • Specify any custom sounds
    • Special any launch images
    • Save registered device id’s in a database

SSL Certificates and Provisioning

The first thing you need to do is set up certificates and provisioning to provide a secure connection for communication between servers and your application. Don’t let this step scare you, it’s not that bad once you do it :). There’s a great article here that documents this process with screenshots and details that you should use for this step. In the next paragraph I attempt to put words to exactly what it is you’re doing and why for those that want to understand better, but feel free to skip that paragraph if you just want to go through the setup using the article.

Certificates and Provisioning Explanation

Basically your application needs to be enabled for push notifications through the Apple iOS Provisioning Portal via an App ID (com.mysite.myapp) and signed with a provisioning profile that includes this push enabled application identifier. The App ID also needs to be associated with an SSL certificate for communicating securely with Apple’s Push Notification Server. When you configure the App ID through the portal, a wizard will prompt you to create an SSL certificate that will be associated with your App ID and used for that purpose. Having the association with the App ID will will ensure the notifications sent from your server to Apple’s APN Server will then be sent to *just* the application with that matching id. Once the certificate process is complete you will need to download a new provisioning file for this new App ID containing the enabled push notifications. You then drag it into XCode and make sure it is the provisioning profile that is selected for your application in the Code Signing screen (under Build Settings for your project).

Setting up your Application

Now that you’re ready to start coding your HTML/JavaScript/PhoneGap application, go through the following steps to set it up:

This article assumes you know how to create a project including PhoneGap/Cordova, if not, please refer to the Getting Started tutorials on the website).
  1. Get the latest PhoneGap Push Notifications plugin from GitHub.
  2. Drag and drop the PushNotification folder to the Plugins folder in XCode and select the “Create groups for any added folders” as the copy option as shown in the screenshot.
  3. Go out of XCode and into Finder and copy the PushNotification.js file into your www folder (or in a subfolder called plugins underneath the www folder to keep it cleaner). It will automatically show up in XCode for you. You cannot drag a file into XCode into this folder because of the way that it’s set up as a folder reference (icon is blue). See the sample project for further reference.
  4. Add a script tag to refer to the PushNotification.js file in your HTML file such as:
    <script src="js/PushNotification.js"></script>

    Rather than adding the PushNotification.js file directly into the www root folder in your Finder, you may want to create a plugins subfolder to contain them in case you end up using others. If you do create that subfolder than your script tag needs to reference the file as below in your HTML instead:

    <script src="js/plugins/PushNotification.js"></script>

  5. Add the plugin key and value to your Cordova.plist (found under your project root Resources folder)

The Cordova PushNotification plugin gives you a nice JavaScript API you can use from your HTML/JS files to interact with the underlying native code for handling the registration and receiving of push notifications. Some of the functions provided are listed here:

  • registerDevice()
  • setApplicationIconBadgeNumber()
  • getRemoteNotificationStatus()
  • getPendingNotifications()

To use it though, you first need to add some things to the native application code to bridge to the specific push notification code. The AppDelegate class for an application (located under your project Classes folder) implements the handlers for application-wide events, such as application launch, termination and more. There are also events available for handling notifications. A list of them can be found here in the Handling Notifications reference. These methods are not implemented by default though, so in order to support them we need to add the code handlers and have them delegate to our included PushNotification.m class in our plugin code. The code to add is shown in the README for the plugin but I’ll paste it here as well for further reference. You’re basically handling three events with it:

  • didReceiveRemoteNotification
  • didRegisterForRemoteNotificationsWithDeviceToken
  • didFailToRegisterForRemoteNotificationsWithError

Add the following code block to your AppDelegate.m class before the @end to handle the notification events:

#pragma PushNotification delegation

- (void)application:(UIApplication*)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
    PushNotification* pushHandler = [self.viewController getCommandInstance:@"PushNotification"];
    [pushHandler didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];

- (void)application:(UIApplication*)app didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
    PushNotification* pushHandler = [self.viewController getCommandInstance:@"PushNotification"];
    [pushHandler didFailToRegisterForRemoteNotificationsWithError:error];

- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
    PushNotification* pushHandler = [self.viewController getCommandInstance:@"PushNotification"];
    NSMutableDictionary* mutableUserInfo = [userInfo mutableCopy];

    // Get application state for iOS4.x+ devices, otherwise assume active
    UIApplicationState appState = UIApplicationStateActive;
    if ([application respondsToSelector:@selector(applicationState)]) {
        appState = application.applicationState;

    [mutableUserInfo setValue:@"0" forKey:@"applicationLaunchNotification"];
    if (appState == UIApplicationStateActive) {
        [mutableUserInfo setValue:@"1" forKey:@"applicationStateActive"];
        [pushHandler didReceiveRemoteNotification:mutableUserInfo];
    } else {
        [mutableUserInfo setValue:@"0" forKey:@"applicationStateActive"];
        [mutableUserInfo setValue:[NSNumber numberWithDouble: [[NSDate date] timeIntervalSince1970]] forKey:@"timestamp"];
        [pushHandler.pendingNotifications addObject:mutableUserInfo];

The above code essentially creates a reference to our PushNotification class, sets or reads some values (not going into detail here to keep this less complicated), and calls different methods with parameters depending on the event that occurred.

Don’t worry if you don’t know any Objective-C or this seems complicated at this point, a sample project has been included here for reference!

The last thing you need to do is add a code fragment into the didFinishLaunchingWithOptions method in that same AppDelegate.m class to handle opening the application from a notification (and adding the received object to the pendingNotifications for later retrieval). Add this block right before the end return YES:

    /* Handler when launching application from push notification */
    // PushNotification - Handle launch from a push notification
    NSDictionary* userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
    if(userInfo) {
        PushNotification *pushHandler = [self.viewController getCommandInstance:@"PushNotification"];
        NSMutableDictionary* mutableUserInfo = [userInfo mutableCopy];
        [mutableUserInfo setValue:@"1" forKey:@"applicationLaunchNotification"];
        [mutableUserInfo setValue:@"0" forKey:@"applicationStateActive"];
        [pushHandler.pendingNotifications addObject:mutableUserInfo];
/* end code block */

PushNotification Plugin – JavaScript APIs

Now that you have the project setup complete including the native Objective-C handlers above, you can actually start coding with the Cordova PushNotification JavaScript interfaces. Below is further detail about some of them and examples of interacting with then in your code. Note: there are others that are available but not covered specifically yet in this post.

Register Device
The PhoneGap PushNotification plugin offers a registerDevice() API to register your application with Apple’s Push Notification Service to receive push notifications. In the function you specify exactly which types of notifications are enabled (alerts/badges/sounds). The result is a unique device token that can then be used by the server-side to send the notification to that device.

Apple recommends you register your application for push notifications on the device every time it’s run since tokens can change. The documentation says: ‘By requesting the device token and passing it to the provider every time your application launches, you help to ensure that the provider has the current token for the device. If a user restores a backup to a device other than the one that the backup was created for (for example, the user migrates data to a new device), he or she must launch the application at least once for it to receive notifications again. If the user restores backup data to a new device or reinstalls the operating system, the device token changes. Moreover, never cache a device token and give that to your provider; always get the token from the system whenever you need it.’

An example of using the registerDevice() function is included in the sample project and is also shown below:

        var pushNotification = window.plugins.pushNotification;
        pushNotification.registerDevice({alert:true, badge:true, sound:true}, function(status) {
            app.myLog.value+=JSON.stringify(['registerDevice status: ', status])+"\n";

Once the above code is in place and your application is run, you will receive an alert like the following prompting if it’s ok to receive push notifications (this results in a setting that can be modified in your device settings as needed):

Get Pending Notifications
Pending notifications are those notifications that are received while the application was not active. When the application is launched you will want to retrieve them so you can handle the data sent to you as needed. The getPendingNotifications() function is available in the API for that purpose. Below is some example code:

        var pushNotification = window.plugins.pushNotification;
        pushNotification.getPendingNotifications(function(notifications) {
            app.myLog.value+=JSON.stringify(['getPendingNotifications', notifications])+"\n";
            console.log(JSON.stringify(['getPendingNotifications', notifications]));

Get Notification Status
This method will return type and which notifications are enabled (alert, sound, badge).

        var pushNotification = window.plugins.pushNotification;
        pushNotification.getRemoteNotificationStatus(function(status) {
            app.myLog.value+=JSON.stringify(['Registration check - getRemoteNotificationStatus', status])+"\n";

Set Badge Number
You will likely need to set the badge number on the application icon as you process the notifications, for instance if you open from a push notification just received, you may want to decrement or clear it. Setting the badge number to 0 will remove or clear the badge as shown below.

        var pushNotification = window.plugins.pushNotification;
        app.myLog.value+="Clear badge... \n";

Anatomy of an Apple Push Notification

The maximum size for a notification payload is 256 bytes. If that limit is exceeded, it will be refused. Also note the delivery of notifications is “best effort” and not guaranteed, according to the Apple documentation, so you should not use it for sending critical or sensitive data, only to notify that new data is available. The notification payload is a JSON dictionary object that needs to contain another dictionary identified by the key aps. The aps dictionary then will contain one or more properties that would specify an alert to display, a number badge to set on the application icon and/or a sound to play when the notification occurs. It’s also possible to create a custom payload but that is beyond the scope of this post. The alert object itself can contain just a string of text to display, OR a dictionary object with keys for a body, custom action button text to display and a custom launch image that can be set. More specific details about the payload can be found here.

Here’s an example of a simple payload in bytes:

A typical aps dictionary object will contain 3 properties; alert, badge and sound, such as shown in the following output:

applicationLaunchNotification = 0;
applicationStateActive = 0;
aps = {
alert = {
“action-loc-key” = Play;
body = “Your turn!”;
“launch-image” = “mysplash.png”;
badge = 5;
sound = “notification-beep.wav”;

messageFrom = Holly;
timestamp = “1350416054.782263”;

Any custom sounds or launch images must be contained in the Resources folder in your project (under XCode)your projects Resources folder in XCode. For example in my image below, I have a notification-beep.wav and mysplash.png specified that I refer to in my push notification coming from the server.

Server-Side Code Handling

Simple Server

Listening for device registration token with Node.js
Below is example code you could use to get started with a server-side solution to handling device token registration which I currently call from my application sample to show how and at which point you might want to communicate with a 3rd party server to store device tokens after receiving the device token from Apple. Currently it doesn’t do anything with the token other than show that it and the message were received, but the next step would be to store the users’s device token and any other information in a database for later use when a push notification needs to be sent (such as shown in the next example). I plan to do a Part 2 series on integrating with MongoDB so check back soon!

var http = require('http');
var apn = require('apn');
var qs = require('querystring');

var server = http.createServer(function (req, res) {
	if(req.method === "POST") {
		var fullBody="";
		req.on('data', function(chunk)	
			fullBody += chunk;
			console.log("Full body " + fullBody);

		req.on('end', function()
			var data = qs.parse(fullBody);
			console.log("Token " +data.token);
			console.log("Message " + data.message);
			var myDevice = new apn.Device(data.token);
			// Now we need to store it! Add code to interface with a db below...

			res.writeHead(200, {"Content-Type": "text/plain"});
			res.end("Thank you for registering\n");
console.log("Server running at"+server.address().port);

Note: I’m simply running this script using Node.js on my localhost. When testing from your actual device (since push notifications are not supported in the emulator), you can set up a Manual HTTP Proxy in your device’s Wi-Fi settings to point to the IP Address of your computer. Go to your Wi-Fi network and scroll to the bottom of the settings to set the Manual Proxy server and port. Here’s an example of mine:

Sending a Notification with node-apn (Node.js API)

Below is an example of some simple code to show how you could use the node-apn open source Node.js API to send a push notification to a users device. I simply hard-coded my device tokens in for quick testing, but ultimately you would be retrieving them from a database (after being stored above) to use for sending the push notifications.

var http = require('http');
var apn = require('apn');
var url = require('url');

var myPhone = "d2d8d2a652148a5cea89d827d23eee0d34447722a2e7defe72fe19d733697fb0";
var myiPad = "51798aaef34f439bbb57d6e668c5c5a780049dae840a0a3626453cd4922bc7ac";

var myDevice = new apn.Device(myPhone);

var note = new apn.Notification();
note.badge = 1;
note.sound = "notification-beep.wav";
note.alert = { "body" : "Your turn!", "action-loc-key" : "Play" , "launch-image" : "mysplash.png"};
note.payload = {'messageFrom': 'Holly'};

note.device = myDevice;

var callback = function(errorNum, notification){
	console.log('Error is: %s', errorNum);
	console.log("Note " + notification);
var options = {
	gateway: 'gateway.sandbox.push.apple.com', // this URL is different for Apple's Production Servers and changes when you go to production
	errorCallback: callback,
	cert: 'PushNotificationSampleCert.pem',                 
	key:  'PushNotificationSampleKey.pem',                 
	passphrase: 'myPassword',                 
	port: 2195,                       
	enhanced: true,                   
	cacheLength: 100                  
var apnsConnection = new apn.Connection(options);
The above code will produce a notification that looks like the following on my device if you have your device Settings->Notifications->MyAppName set to Alerts:

If you’re device settings for Alert Style on the application is set to Banners, it will look like this:

Important Note: You need to change the .pem files to your cert and private key created in the setup (the ones you ultimately combined into a single .pem with instructions from here. Remember you first converted the .cer to a .pem, and then your .p12 to a .pem, those are the two files needed here – see this readme for more details on parameters). In my example, my .pem files are in the same folder as my Node.js code. You can omit the password property if you did not keep a password on them.
There’s also a PHP Push Notifications API called APNS-PHP if you prefer to use PHP as your language of choice…

Sample Project

I’ve included a link to a sample project on GitHub that I created for a reference application since it includes everything discussed above already in place. You can’t actually use this project out of the box because you have to have your own uniqe App ID and Provisioning files set on your project for it so you are better off starting your own project from scratch and using mine for reference only. I created this project to eventually be cross-platform using the cordova-client tool, but currently only iOS is setup so refer to the PGPushNotificationSample/platforms/ios path for the iOS specific code. You’ll find all of the JavaScript functions in the PGPushNotificationSample/platforms/ios/www/js/index.js file. I chose straight JavaScript in favor of simplicity. It also does an XMLHttpRequest to my simple server code (example shown above) and sends the device token received from the registration.

Check back soon for more posts to come related to this topic!

Related Links

Local versus Push Notifications (in-depth explanation from Apple)
Apple Push Service Details
Apple Push Notification Services Tutorial by Ray Wenderlich
Apple Push Notifications Provider Server Tutorial
Apple Push Notifications API in Node.js
APNS-PHP – Apple Push Notifications API for PHP

Filed in: CordovaMobile DevelopmentPhoneGap Tags:

About the Author ()

Comments (30)

Trackback URL | Comments RSS Feed

  1. Kent says:

    Nice Article!!
    Got any js can direct take the deviceToken?

  2. Ajar says:

    Hi everyone
    For those of you coming back to this blog hoping to get some flash love
    If you feel like writing your apps & games for the mobile in Flash/Flex AS3, you can find a whole market of native extensions, among them also native push notifications:



  3. Amaan says:

    i have done all the things, also got device token, but when i run php code to send notification, its sent from server but there is no any alert notification in the iPhone.

    even server says : “Connected to APNS 101Message successfully delivered”

    any help????

  4. Please note I will be hosting two webinars on push notifications for Android and iOS in February via TechLive. The webinar for Apple Push Notifications handling in a PhoneGap application will be held on Feb 8th and the Android push notification with PhoneGap session on Feb 22nd so plan to attend or view the recordings that will be posted after.

  5. Safrul says:

    Nice article! thanks for sharing! 🙂

  6. Atif Sultan says:

    Based on the steps from this article, I am able to receive push notifications but when the app is closed my getPendingNotifications is not called at all. I do see the notification and when I click on it the App opens up. Any idea why my getPendingNotifications is not being called?

  7. jongwoo Yoo says:

    thank you support tutorial~!! ^^

  8. Vasilis says:

    Why theres no cordova.plist file on the latest version of cordova? What do we do in this case? I m so confused now , how can i enable the plugin without it?

  9. Vasilis says:

    Holly thank you very much , i finally made it work. But i have another interesting question. In the case , that i am using an external url and not a local index.html , how do i load the plugin for the pushnotification? Because if i let the calls of the javascript on the local index.html , they are never called and i dont have push notifications. I tried to include them on my external URL that i call but again it doesnt work (PushNotifications are not enabled)

  10. Vasilis says:

    In the latest cordova version 2-5-0 theres not JSONKit.m/h. The pushnotification plugin imports this class so i get an error. I comment the line where i import it , but then when i get the push and the application is in the foreground i get a crash. If the app is in background it works well.Any ideas?

  11. grrd says:

    Hi Vasilis,

    Use CDVJSON instead, and it will work. Change the import to


    and the line

    NSString *jsStatement = [NSString stringWithFormat:@”window.plugins.pushNotification.notificationCallback(%@);”, [userInfo cdvjk_JSONString]];

    should be

    NSString *jsStatement = [NSString stringWithFormat:@”window.plugins.pushNotification.notificationCallback(%@);”, [userInfo JSONString]];

  12. grrd says:

    OK, seems like the lessthan/greaterthan characters are not allowed 🙂 In my comment above the import should be


    instead of Cordova/JSONKIT.h

  13. Vasilis says:

    Thanks a lot grrd! Holly do you know if theres a plugin like this or like the android one , for the windows phone 7 or blackberry platform? I am trying to find something relevant the last days but without any luck. The only result i always stumble on is the pushwoosh solution. However i need to use my own servers to handle/send my notifications , so the code is pretty much useless for me. Any ideas? Or is it easy to change the pushwoosh windows phone 7 code , to make it work with my server?

  14. art says:

    I came across a bit late on this tutorial which can be understood either by intermediate web developper or even newbies.
    I would point out 3 facts that could help later people implementing APN on their phone gap app :
    1) the « OpenUDID » files from ylechelle available here https://github.com/ylechelle/OpenUDID on github are missing.
    the « AppDelegate.h » or « AppDelegate.m » made an import to OpenUdid files, so xcode will be unable to build your project and trigger a « file not found error » without them.
    2) In the version (when i write this lines of phonegap : 2.6.0), you need to add the var name and values « PushNotification » in the « config.xml » files (just before the « www » directory in the tags and not anymore in the « Cordova.plist » because it does not exist anymore.
    3) Next I have noticed that in the sample projects of holly schinsky available here (https://github.com/hollyschinsky/PGPushNotificationSample/blob/master/platforms/ios/www/js/index.js)any call to the alert(); function in the index.js file (inside app object) will not work, then it harden the process of debugging.
    (but it can be a misconfiguration on my files or a soft somewhere…)
    Instead if you need to debug your application you can make some alert() ; in the body of the of your enventlistener « deviceready » fonction. Here they appears to work properly…
    4) Last (but may be not least for the future), I have noticed a weird demeanor with the registerDevice() ; method which is that the properity « status.deviceToken » will return « undefined » if you place it after
    app.myLog.value+=JSON.stringify([‘registerDevice status: ‘, status])+”\n”;
    as it is coded in the sample and pluggin. But it will return the wanted token before (namely just after  pushNotification.registerDevice();)
    Hope this will help someone…

  15. Cesar says:

    I’ve followed the tutorial and used the following line in my config.xml. However, it is not registering the device. Any help would be appreciated. Thank you.

  16. Nil says:

    Nice article! thanks alot

  17. Ashton says:

    Quick question about viability, as was pointed out by art above, the cordova push plugin that you link to requires OpenUDID. (https://github.com/mgcrea/cordova-push-notification/issues/14)

    (the last import in PushNotification.m)

    The github page for OpenUDID is plastered with parnings that it’s been deprecated, and not only that, but if you do drop it into a project and try to build, it’s riddled with ARC errors.

    So now that question: As a result of OpenUDID getting deprecated, has this tutorial been deprecated (in favor of https://github.com/phonegap-build/PushPlugin perhaps)?


  18. Gerardo says:

    Holy, I do not have words to describe how thankful I am with your tutorials and code examples, I had to do a few changes in order to have my application working with PushPlugin for both, Android and iOS, Thank you very much!!!

  19. Brandon says:

    This is so outdated that none of it will work.

    This is honestly a very big mess. I’ve tried everything to make this work, but with the changes to phonegap build, phonegap and the push plugin, this tutorial doesn’t make any more sense.

    PushNotification class is not found. Pushnotification.h does not exist, the installation of the push plugin on here does not match the push plugin documentation. Some links so longer work.

    At the very least I want debugging to work. Nope. I use the CLI to install the console plugin but no errors show for the javascript. Phonegap-hosted Weinre did not work. I can’t seem to get the the local server to work through a local wifi connection because it’s blocked somehow.

    Where’s a tutorial that actually works?

    • Brandon, that tutorial was written last year and based on older versions of everything. There’s one here that is more recent: http://devgirl.org/2013/07/17/tutorial-implement-push-notifications-in-your-phonegap-application/. Hope that helps! Holly

      • Brandon says:

        Wow, it’s great to get a response from you!

        Yes, I’ve been looking through that one as well. I eventually got it working through slightly different means.

        I was using the CLI for Phonegap version 3.10-0.15.0 and adding the plugins that way did not seem to work. I was trying to get the console logger to work before I added the push plugin. It appears the ‘phonegap plugin add’ operation is broken. It doesn’t place the proper native files in the plugin directory, and even if you place them in, it won’t compile due to some other issue.

        Also, there is something else that may be wrong in the example set up here for the iOS platform: https://github.com/hollyschinsky/PushNotificationSample30/tree/master/platforms/ios/www

        Phonegap.js is referenced, but is not present in the directory for the iOS platform. Everything else seems to be okay in the www file but I’m not sure as I wasn’t able to get that working.

        I solved it by installing Cordova 3.1. I built the app, prepared iOS, added the certificate and provisioning profile to Xcode, added the console plugin, added the push plugin and that was it. I didn’t need to do any other copying. I just added the code you have in index.js, which I got from the pushplugin github page.

        At first I thought I was doing something wrong because I didn’t get a confirming message asking if Push was okay. All is good now- apparently that’s not needed.

        I do have a question though. Should I be using Cordova from now on or PhoneGap?

        Here: http://docs.phonegap.com/en/3.1.0/guide_cli_index.md.html#The%20Command-line%20Interface

        It’s saying Cordova for 3.1, which pushed me to try it out. I suggest PhoneDova or CordoGap, as I saw someone else mention :).

Leave a Reply