📜 ⬆️ ⬇️

How to send a push notification to iphone from your script using Boxcar 2 for free

There was a task to send alerts to iphone. Of course, it would be easier to do this with regular email, but the client insisted on pushing it. So I had to use the search. To my surprise, neither on Habré nor in the Russian part of the Internet there was a working example of how to make a free push. It would be necessary to fix it.

We will need to install the free Boxcar 2 application, as well as in our script there should be support for CURL.


')
Under the cat is a step by step guide and an example in php.

Step 1. Install on iphone Boxcar 2 .

Step 2. Take Access Token from the settings



Step 3. In our script, add the following CURL command:

curl -d "user_credentials=ACCESS_TOKEN" \
-d "notification[title]=message title" \
-d "notification[long_message]= Some text or HTML for the full layout page notification " \
-d "notification[sound]=bird-1" \
-d "notification[source_name]=My own alert" \
new.boxcar.io/api/notifications


Parameters have the following meanings:



It is clear that it is necessary to write programming in your language. For example, this is how it looks in php:

 function boxcar($title,$message){ curl_setopt_array( $curl = curl_init(), array( CURLOPT_URL => "https://new.boxcar.io/api/notifications", CURLOPT_POSTFIELDS => array( "user_credentials" => '  Access Token', "notification[title]" => $title, "notification[long_message]" => $message, "notification[sound]" => "bird-1", "notification[source_name]" => "test" ))); $ret = curl_exec($curl); curl_close($curl); return $ret; } boxcar('Hello World','The world is mine! <b>He-he-he</b>'); 


In fact, this is a translation of an example from a reference , but I hope someone will save time when searching.

Source: https://habr.com/ru/post/225143/


All Articles