Push notification is not receiving on device
I am using push notification through PHP script. Code seems to be working fine, it does not give me any error. But notification does not receive me on my device.
Here is my code:
$passphrase = '123'; $ctx = stream_context_create(); stream_context_set_option($ctx, 'ssl', 'local_cert', 'cert.pem'); stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase); $fp = stream_socket_client( 'ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx); // Create the payload body $body['aps'] = array( 'alert' => $message, 'sound' => 'default' ); // Encode the payload as JSON $payload = json_encode($body); // Build the binary notification $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
Can anyone suggest what is wrong in it.
- Adding text field in Remote Notification, iOS 8
- how to handle multiple devices when using Push Notification?
- Can apple push notifications send more parameters than alert and sound?
- Simpler push-notification, perhaps ask server if there is any?
- iOS Push Notification Banner shown twice for a single Push
- Send push notification from ios app
Solutions Collect From Internet About “Push notification is not receiving on device”
try this php code:
but you have to change device token and passpharse as you had set. you can download php script from below link
i have run this php script it’s works well..
- a Custom Segue that Simulates a Push Segue turns VC into Zombie
- Storing to a variable vs passing directly (does that implicitly create a temp variable?)
- CommonCrypto isn't building for arch armv7 iOS
- xCode long freezes after upgrading to 4.3.2
- How to check if user is logged in with FBSDKLoginKit in iOS?
- Open Twitter Setting from ACAccountStore (iOS 5.1 TWITTER)
- Orienting iOS splash image to landscape/portrait according to launch orientation
- EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
- How to tap to zoom and double tap to zoom out in iOS?
- iphone – writeToFile not saving new entry into plist
- How to determine Internet Connection in Cocoa?
- IOS Bluetooth not discovering peripheral services. (sometimes!)
- How to sort a fetch in Core Data
- xcode – How do I keep views locked into portrait mode, but still allow one view to rotate?
- How can I receive push notifications of an other app?