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

iOS9 iTune Upload Error : Invalid Bundle. iPad Multitasking support requires launch story board in bundle

1. Add the UIRequiresFullScreen key to your Xcode project’s Info.plist file and apply the Boolean value YES 2. This will fix one more issue that is coming at the time of iTune upload Invalid Bundle. iPad Multitasking support requires these orientations: 'UIInterfaceOrientationPortrait,UIInterfaceOrientationPortraitUpsideDown,UIInterfaceOrientationLandscapeLeft,UIInterfaceOrientationLandscapeRight'. If your application only using single orientation then use the above keyword in info.plist

Code Review Tool for Objective-C

Clang Static Analyzer The Clang Static Analyzer is a source code analysis tool that finds bugs in C, C++, and Objective-C programs. Currently it can be run either as a  standalone tool  or  within Xcode . The standalone tool is invoked from the command line, and is intended to be run in tandem with a build of a codebase. The analyzer is 100% open source and is part of the  Clang project. Like the rest of Clang, the analyzer is implemented as a C++ library that can be used by other tools and applications. Download Mac OS X Latest build (Intel-only binary, 10.5+): checker-275.tar.bz2  (built May 23, 2013) Release notes This build can be used both from the command line and from within Xcode Installation  and  usage Other Platforms For other platforms, please follow the instructions for  building the analyzer  from source code. Viewing static analyzer results in Xcode Viewing static analyzer results in a web ...