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.
- SKStoreReviewController buttons hidden under keyboard
- kGAIScreenName of Google Analytics for iOS v3 is undeclared?
- UILabel auto resize on basis of text to be shown
- How did Whatsapp app removed app's compatibility for iPad?
- Recovery deleted files from Xcode
- Using JSON Encoder to encode a variable with Codable as type
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..
- Storyboard prepareForSegue
- UIWindow? does not have member named bounds
- Two ModalViewController
- How to load viewcontroller without button in storyboard?
- Swift 2.0 Xcode 7.1 image picker front camera image rotated when picked
- iOS measuring web page loading time
- Integrate Fabric/Crashlytics via CocoaPods
- UICollectionView sticky header in swift
- IOS7 Status bar hide/show on select controllers
- Apply Custom font to Attributed string Which Converts from HTML String
- Optional type '$T11' cannot be used as a boolean; test for '!= nil' instead since installing XCode 6 beta 7
- Bullet list and Numbered list in UITextView
- How to scroll view up when keyboard appears?
- Objective-C 101 (retain vs assign) NSString
- Atos does not symbolicate system frameworks/libraries properly