-
Notifications
You must be signed in to change notification settings - Fork 996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for BigPictureStyle #498
base: master
Are you sure you want to change the base?
Conversation
…re' along with extras
+1 |
1 similar comment
+1 |
👍 |
how to implement this..can someone help me ? |
@atompailey Since this PR is not merged yet, you could install the plugin from my fork. |
so how can we actually implement this ? |
Example Code GCM php That however does not work and can price an example PHP page and plug-in ?? HELPMEEEEEEE!!! PAGE PHP------------------------------------------------------------------------------------------------------------------------ serverApiKey = $apiKeyIn; } function setDevices($deviceIds){ if(is_array($deviceIds)){ $this->devices = $deviceIds; } else { $this->devices = array($deviceIds); } } function send($message, $data = false){ if(!is_array($this->devices) || count($this->devices) == 0){ $this->error("No devices set"); } if(strlen($this->serverApiKey) < 8){ $this->error("Server API Key not set"); } $fields = array( 'registration_ids' => $this->devices, 'data' => array( "message" => $message ), //'data' => array("message" => $message,"count" => $count,"BigPicture" => $BigPicture ), ); if(is_array($data)){ foreach ($data as $key => $value) { $fields['data'][$key] = $value; } } $headers = array( 'Authorization: key=' . $this->serverApiKey, 'Content-Type: application/json' ); $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $this->url ); curl_setopt( $ch, CURLOPT_POST, true ); curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields ) ); curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($ch); curl_close($ch); return $result; } function error($msg){ echo "Android send notification failed with error:"; echo "\t" . $msg; exit(1); } ``` } if(isset($_POST) && !empty($_POST)){ $apiKey = $_POST["apiKey"]; // CAPI Key GCM ... $devicesToken = explode(",",$_POST["devices"]); // Tokens dispositivo $gcpm = new GCMPushMessage($apiKey); $gcpm->setDevices($devicesToken); ``` $title = $_POST["title"]; $BigPicture = $_POST["BigPicture"]; $message = $_POST["message"]; // Messaggio contenuti PUSH ... $response = $gcpm->send($message, array('title' => $title,'BigPicture' => $BigPicture)); // Titolo spinta ... //$response = $gcpm->send($message, array('title' => $title)); echo $response; ``` } ## ?>SCRIPT -------------------------------------------------------------------------------------------------------------------------- <script type="text/javascript"> var pushNotification; var tokenID; function onDeviceReady() { $("#console").append('-> funzione push avviata! '); // Instanciando plugin Push... pushNotification = window.plugins.pushNotification; // Iniciar serviço de Push no aplicativo... pushNotification.register( function (result) { $("#console").append('-> SUCESSO: '+ result+' '); }, function (error) { $("#console").append('-> ERRO: '+error+' '); }, { "senderID":"786971128159", "ecb":"capturarEventos" } ); } // capturar notificações recebidos da API Google Cloud Messaging (GCM)... function capturarEventos(e) { $("#console").append('->-> evento catturato:' + e.event); //alert(e.event); // riguarda se il dispositivo e registrato a no da google switch( e.event ) { // Dispositivo registrado no GCM!!! case 'registered': $("#console").append('-> dispositivo registrato' + e.regid+' '); console.log("TOKEN = " + e.regid); //ricevi il token id// tokenID = e.regid; break; //invio tokenID tramite £post// // rivevuto push!!! case 'message': // Verificare messaggio push è arrivato con l'applicazione aperta (in primo piano) ... // Se è così, abbiamo lanciato un allarme (suono, finestre, ecc) per attirare l'attenzione ... if (e.foreground) { $("#console").append('PUSH CATTURATO CON APP APERTA! '); intel.xdk.notification.alert(e.payload.message + " " + e.payload.BigPicture + " ", e.payload.title + " ", "Conferma"); } else { // In caso contrario sono stati rilasciati perché l'utente ha toccato una notifica nella barra di notifica ... if (e.coldstart) $("#console").append('-> CAPTURADO PUSH COM APP EM COLDSTART! '); else $("#console").append('-> CAPTURADO PUSH COM APP EM BACKGROUND! '); } // Compondo mensagem... //alert('message = '+e.message+' msgcnt = '+e.msgcnt); $("#console").append('-> MENSAGEM: ' + e.payload.message + ' '); $("#console").append('-> MENSAGEM: ' + e.payload.title + ' '); $("#console").append('-> MENSAGEM: ' + e.payload.count + ' '); $("#console").append('-> MENSAGEM: ' + e.payload.sound + ' '); $("#console").append('-> MENSAGEM: ' + e.payload.BigPicture + ' '); break; case 'error': $("#console").append('-> ERRO:' + e.msg+' ' ); alert(e.msg); break; default: $("#console").append('-> EVENTO: Desconhecido, um envento estranho foi capturado. '); break; } } document.addEventListener('app.Ready', onDeviceReady, true); </script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed
To send a BigPicture Notification (large image in notification), send a url in 'bigPicture'