{"action":"created","issue":{"url":"https://api.github.com/repos/AppGyver/PushNotifications/issues/20","labels_url":"https://api.github.com/repos/AppGyver/PushNotifications/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/AppGyver/PushNotifications/issues/20/comments","events_url":"https://api.github.com/repos/AppGyver/PushNotifications/issues/20/events","html_url":"https://github.com/AppGyver/PushNotifications/issues/20","id":61204331,"number":20,"title":"Not receiving notifications on iOS after registration","user":{"login":"MaksaPN","id":2012948,"avatar_url":"https://avatars.githubusercontent.com/u/2012948?v=3","gravatar_id":"","url":"https://api.github.com/users/MaksaPN","html_url":"https://github.com/MaksaPN","followers_url":"https://api.github.com/users/MaksaPN/followers","following_url":"https://api.github.com/users/MaksaPN/following{/other_user}","gists_url":"https://api.github.com/users/MaksaPN/gists{/gist_id}","starred_url":"https://api.github.com/users/MaksaPN/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaksaPN/subscriptions","organizations_url":"https://api.github.com/users/MaksaPN/orgs","repos_url":"https://api.github.com/users/MaksaPN/repos","events_url":"https://api.github.com/users/MaksaPN/events{/privacy}","received_events_url":"https://api.github.com/users/MaksaPN/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-03-13T19:44:51Z","updated_at":"2015-03-16T15:31:31Z","closed_at":"2015-03-16T15:31:31Z","body":"Hello guys,\r\n\r\nI hope this is the place where I should ask this question, if not, my apologies and could you direct me where should I ask this.\r\n\r\nI have ran into a problem with push notifications for iOS. The logic is as simple as it gets: you register to receive notifications and then subscribe to receive foreground and background notifications. This works properly on Android but, for some reason, it does not work on iOS.\r\n\r\nI have tried everything I could think of and left with no further ideas. First of all I have verified that my Laravel API is sending the notifications correctly with a colleague who is an  iOS developer, who created a sample app to receive notifications from our API, which he had received successfully.\r\n\r\nI have forked the plugin's repository and changed the iOS executable code and placed (again, with assistance from a colleague who is an iOS developer) alerts everywhere to see through the process from iOS perspective. Once again, I have confirmed that iOS application registers for push notifications and starts the subscribe channel, but yet again the application was unable to receive a notification. Note: I have enabled push notifications, and the app shows up in the list on the device apps which have enabled notifications. I have also tried with your Ruby sample server and got identical results - the native application receives the notification without any issues.\r\n\r\nFurther on, I have created a sample app from scratch, just to see if I could get it to receive and eliminate possible issues with the setup in my original application. Test application also failed to receive any notifications on iOS. This is the test application Appgyver address, if that can help: https://cloud.appgyver.com/applications/50462. \r\n\r\nThis is my code on the client side:\r\n\r\n    function registrationHandler(deviceToken) {\r\n        if (deviceToken != dataService.getDeviceToken()) {\r\n            dataService.setDeviceToken(deviceToken);\r\n        }\r\n        window.plugins.pushNotification.onMessageInForeground(messageInForegroundHandler, errorHandler);\r\n        window.plugins.pushNotification.onMessageInBackground(messageInBackgroundHandler, errorHandler);\r\n    }\r\n    function errorHandler(error) {\r\n        alert('Error occured - ' + error);\r\n    }\r\n    function messageInForegroundHandler(notification) {\r\n        var message = notification.message || notification.alert;\r\n        console.log(message);\r\n    }\r\n    function messageInBackgroundHandler(notification) {\r\n        var message = notification.message || notification.alert;\r\n        if (notification.coldstart) {\r\n            console.log(message);\r\n        }\r\n        else {\r\n            console.log(message);\r\n        }\r\n    }\r\n    document.addEventListener(\"deviceready\", function () {\r\n        if (device.platform == 'android' || device.platform == 'Android') {\r\n            window.plugins.pushNotification.register(\r\n                registrationHandler,\r\n                errorHandler, {\r\n                    \"senderID\": \"<MY-APP-ID>\"\r\n                });\r\n        }\r\n        else if (device.platform == \"ios\" || device.platform == \"iOS\") {\r\n            window.plugins.pushNotification.register(\r\n                registrationHandler,\r\n                errorHandler, {\r\n                    \"badge\": \"false\",\r\n                    \"sound\": \"true\",\r\n                    \"alert\": \"true\"\r\n                });\r\n        }\r\n    });\r\n\r\nThis is my code on the server side (PHP - Laravel 5):\r\n\r\n    public function sendiOSPush($userId, $messageArray)\r\n    {\r\n        $deviceTokens = $this->users->find($userId)->iOsTokens()->get();\r\n    \r\n        $passphrase = '<MY-CERTS-PASSPHRASE>';\r\n        $message = json_encode($messageArray, JSON_PRETTY_PRINT);\r\n        \r\n        foreach($deviceTokens as $deviceToken)\r\n        {\r\n            $ctx = stream_context_create();\r\n            stream_context_set_option($ctx, 'ssl', 'local_cert', public_path().'/ck.pem');\r\n            stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);\r\n        \r\n            $fp = stream_socket_client(\r\n                'ssl://gateway.sandbox.push.apple.com:2195', $err,\r\n                $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);\r\n\r\n            if (!$fp)\r\n                exit(\"Failed to connect!\" . PHP_EOL);\r\n\r\n            $body['aps'] = array\r\n            (\r\n                'alert' => $messageArray[\"subtitle\"],\r\n                'sound' => 'default'\r\n            );\r\n            \r\n            $body['payload'] = json_encode($messageArray[\"payload\"], JSON_PRETTY_PRINT);\r\n            $body['type'] = $messageArray[\"type\"];\r\n\r\n            $payload = json_encode($body);\r\n            $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken->token) . pack('n', strlen($payload)) . $payload;\r\n            $result = fwrite($fp, $msg, strlen($msg));\r\n            fclose($fp);\r\n        }\r\n        \r\n        return true;\r\n    }\r\n\r\nThank you in advance for your help."},"comment":{"url":"https://api.github.com/repos/AppGyver/PushNotifications/issues/comments/81739920","html_url":"https://github.com/AppGyver/PushNotifications/issues/20#issuecomment-81739920","issue_url":"https://api.github.com/repos/AppGyver/PushNotifications/issues/20","id":81739920,"user":{"login":"MaksaPN","id":2012948,"avatar_url":"https://avatars.githubusercontent.com/u/2012948?v=3","gravatar_id":"","url":"https://api.github.com/users/MaksaPN","html_url":"https://github.com/MaksaPN","followers_url":"https://api.github.com/users/MaksaPN/followers","following_url":"https://api.github.com/users/MaksaPN/following{/other_user}","gists_url":"https://api.github.com/users/MaksaPN/gists{/gist_id}","starred_url":"https://api.github.com/users/MaksaPN/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaksaPN/subscriptions","organizations_url":"https://api.github.com/users/MaksaPN/orgs","repos_url":"https://api.github.com/users/MaksaPN/repos","events_url":"https://api.github.com/users/MaksaPN/events{/privacy}","received_events_url":"https://api.github.com/users/MaksaPN/received_events","type":"User","site_admin":false},"created_at":"2015-03-16T15:31:31Z","updated_at":"2015-03-16T15:31:31Z","body":"@fidoboy\r\nYes, the production certificate is used and like I said, using the built certificates I've build the native iOS app and received the push notifications without any issues. \r\n"}}