JavaScript Implement Ionic push notification

I am Implementing push notification in ionic using this tutorial: http://devdactic.com/ionic-push-notifications/

I have succesfully done using this. I got device token: like:

Got token: DEV-f30dac7a-d761-4a4c-a579-01918b9662ad none

When I use this in following php script:

<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'apikey' );
$registrationIds = array( 'f30dac7a-d761-4a4c-a579-01918b9662ad' );
// prep the bundle
$msg = array
(
    'message'   => 'here is a message. message',
    'title'     => 'This is a title. title',
    'subtitle'  => 'This is a subtitle. subtitle',
    'tickerText'    => 'Ticker text here...Ticker text here...Ticker text here',
    'vibrate'   => 1,
    'sound'     => 1,
    'largeIcon' => 'large_icon',
    'smallIcon' => 'small_icon'
);
$fields = array
(
    'registration_ids'  => $registrationIds,
    'data'          => $msg
);

$headers = array
(
    'Authorization: key=' . API_ACCESS_KEY,
    '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;

I got error like:

{`"multicast_id":6920644147476475688,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}`

I dont Know where I am wrong.Please Help

Answer:1

The error says that your app is not registred. Make sure you put your GCM API key in 'apikey'.

Answer:2

I have an empty-star button like this, <button type="button" class="btn btn-default btn-lg" id="refresh"> <span class="glyphicon glyphicon-star-empty"></span> </button> ...

I have an empty-star button like this, <button type="button" class="btn btn-default btn-lg" id="refresh"> <span class="glyphicon glyphicon-star-empty"></span> </button> ...

I am trying to update other user's information in Parse which is stored in User class. Initially I tried following code: 1. var user = Parse.User; var query = new Parse.Query(user); query.equalTo("...

I am trying to update other user's information in Parse which is stored in User class. Initially I tried following code: 1. var user = Parse.User; var query = new Parse.Query(user); query.equalTo("...

I'm using sw-toolbox, which is a library for service-worker provided by Google. I'd like to combine the cacheFirst strategy (see readme in link above) with a fetch from network after successfully ...

I'm using sw-toolbox, which is a library for service-worker provided by Google. I'd like to combine the cacheFirst strategy (see readme in link above) with a fetch from network after successfully ...

  1. force service worker update
  2. force reload service worker
  3. force unregister service worker
  4. force clear service worker cache
  5. force install service worker
  6. firefox force service worker update
  7. service worker force update cache
  8. service worker force update on reload
  9. service worker force activate

I have this Unicode character that I want to display using the new Unicode Point Escapes (i.e.e where someone uses '\u{Code Point Here}' However, I must be doing something wrong because doing ...

I have this Unicode character that I want to display using the new Unicode Point Escapes (i.e.e where someone uses '\u{Code Point Here}' However, I must be doing something wrong because doing ...