Send push notification


#1

Hello,

I have a small project with arduino and a ionic app
I want send a push notification from arduino with an API request

Can i use ionic push (api available ?) from Arduino to send a push notifcation on a Android with ionic App ?

Thanks in advance :slight_smile:


#2

Go through following link

http://devgirl.org/2013/07/17/tutorial-implement-push-notifications-in-your-phonegap-application/


#3

hmm okay but how the arduino can send a push notification with your system ?


#4

For that you need to write a PHP or java code at the server side here is PHP code for it

<?php // API access key from Google API's Console define( 'API_ACCESS_KEY', 'AIzaSyA8rLfwdsVtPCFaBHe-Did1b7gUA2znooI' ); $registrationIds = array( 'APA91bFq_U_VaX_MDBbYBX-KYbMBQYCYrKDYJHxJ0KaM3qCCI9BfT1bOB19R2_cszDgy7vXa8Bx0_08EiRJwPXL1iULvTphoKuLT1GExyV5W-_H518mTxWCEnv4u9n_rRE8wjLnkKeR5W2onKBxtm-Rff70RnrNtpw' ); // prep the bundle $msg = array ( 'message' => 'The match is postponed due to heavy sunshine', 'title' => 'This is a title. title', 'subtitle' => 'This is a subtitle. subtitle', 'tickerText' => 'The match is postponed due to heavy sunshine', 'vibrate' => 1, 'sound' => 1, 'largeIcon' => 'large_icon', 'smallIcon' => 'small_icon', 'tourID' => '13', 'matchId' =>'143' ); $fields = array ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = array ( 'Authorization: key=' . 'AIzaSyA8rLfwdsVtPCFaBHe-Did1b7gUA2znooI', 'Content-Type: application/json' ); $ch = curl_init(); curl_setopt( $ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send' ); curl_setopt( $ch,CURLOPT_POST, true ); curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers ); curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false ); curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) ); $result = curl_exec($ch ); curl_close( $ch ); echo $result;