Skip to main content

Push Notification

How to send push notification by web interface:

http://www.macoscoders.com/2009/05/17/iphone-apple-push-notification-service-apns/comment-page-1/


Other Link:

 1. http://iphonesdkdev.blogspot.com/2009/04/apns-client-development-certificate.html


2. http://mobiforge.com/developing/story/programming-apple-push-notification-services
 

Commands to create pem file:


  1. openssl pkcs12 -clcerts -nokeys -out cert.pem -in cert.p12
  2. openssl pkcs12 -nocerts -out key.pem -in key.p12
  3. openssl rsa -in key.pem -out key.unencrypted.pem
  4. cat cert.pem key.unencrypted.pem > ck.pem







error_reporting(0);

$deviceToken = '144ed2a746e7fe2de57aa9307a91e6a2f001cc62f3608515a46a1b90c8625e06';
// Passphrase for the private key (ck.pem file)
// $pass = '';

// Get the parameters from http get or from command line
$message = $_GET['message'] or $message = $argv[1] or $message = 'Message received from javacom';
$badge = (int)$_GET['badge'] or $badge = (int)$argv[2];
$sound = $_GET['sound'] or $sound = $argv[3];
// Construct the notification payload
$body = array();
$body['aps'] = array('alert' => $message);
if ($badge)
$body['aps']['badge'] = $badge;
if ($sound)
$body['aps']['sound'] = $sound;
/* End of Configurable Items */
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert','ck.pem');
// assume the private key passphase was removed.
// stream_context_set_option($ctx, 'ssl', 'passphrase', $pass);
$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
if (!$fp) {
print "Failed to connect $err $errstrn";
return;
}
else {
print "Connection OK";
}
$payload = json_encode($body);
$msg = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack("n",strlen($payload)) . $payload;
print "sending message :" . $payload . "***";
fwrite($fp, $msg);
fclose($fp);
?>

Comments

Popular posts from this blog

iOS Beta Builder

Download iOS Beta Builder 1.0 While I’ve been working on iOS for awhile, I don’t have a ton of experience with Cocoa proper – I’m sure there are probably some issues that slipped through the testing process. Screenshots:   How Does It Work? 1. Build your .ipa file using Xcode’s ‘Build and Archive’ option. Choose ‘Save to Disk’. 2. Launch BetaBuilder (or drag and drop the .ipa on to it). If you need to, select your .ipa file. The app should pre-fill the other details. 3. Enter your intended deployment URL. This is the URL on the Web where your beta will be posted / viewed in a browser. This info gets baked into the deployment file. 4. Hit ‘Generate Deployment Files’ and pick a location to output the files. That’s it – just upload the generated files to your Web server and then hit the URL in the device’s browser. BetaBuilder simply generates the HTML and manifest files needed to make wireless distribution work. As a convenience, it also bundles an iTunes install...

Fixed : App crash on update with core data changes

Why migration required ? When the model does not match the store, a migration is required. In order to perform a migration, Core Data (technically, an instance of NSMigrationManager) requires these things: The destination managed object model (the one with the changes) A managed object model that can open the existing store The ability to infer mapping between the two models (for a lightweight migration), or a manual mapping model Permission to attempt to perform an automatic migration (for a lightweight migration) It is therefore absolutely essential that you never make changes to the managed object model for a released version of an app. That is, if your app is already in the App Store,  don’t change a single thing in that version of the managed object model . Solution for the Crash while update an application from the app store: Create a  new version  of the managed object model! This reminds me to mention some other best practices to adopt when worki...