Ionic Push Notification - Android and iOS working

you mean add device registration_id instead of add SENDER_ID which is created from firebase app to here

<plugin name="phonegap-plugin-push" spec="1.10.5">    
  <variable name="SENDER_ID" value="YOUR_SENDER_ID"/>   
</plugin>

Is the below uuid that was mentioned by you as the registration_id

this.uniqueDeviceID.get()
  .then((uuid: any) => console.log(uuid))
  .catch((error: any) => console.log(error));

@newBeat No, that’s the device unique id related to your application. By registration_id I mean the token you receive when you subscribe to push notifications:


push.on('registration').subscribe(data => {
    console.log("device token ->", data.registrationId);
    //TODO - send device token to server
});

Then in your server (back-end) you send it to the device with that token. If it’s an Android device you can send it like:

{
    "registration_ids": [registrationId],
    "data": {
        "title": "My Title",
        "message": "My message!"
    }
}

For more info:

Note: The SENDER_ID (I’m assuming you are using FCM) is the your FCM Project Id (it is the same for all users of your app and is related to your FCM project). In the new versions of phonegap-plugin-push you don’t inform the SENDER_ID anymore, you use a file google-services.json. It is not related to the device token.

1 Like

@ManOnMission Your description is not very clear, please, clarify. From what I see in your log, the first should not be the device token, only the second (FCM Registration Id). Is that your android log and you don’t receive anything in iOS?

Try to put a logs right before the registration call and inside your subscription (both in success and error):

console.log('registration (before)');

push.on('registration').subscribe(
	data => console.log('registration data', data),
	error => console.error('registration error', error),
);

Thank you @lucasbasquerotto. You saved me this time. It works perectly.

OneSignal is a wonderful plugin.

I am not receiving the proper fcm token for ios using the following code

const pushObject: PushObject = this.push.init(options);
pushObject.on('registration').subscribe((data: any) => {
  this.user.token = data.registrationId;
});

it generates like this:
fPUhdRK78aI:APA91bFn3lozqE6MKz3WLWzvaFngquYGEmh_hawoachcFlld-
juxljkacmfm1Qg_VoAIJ4meZK7Nps1of22leZ-vXo3csXUAIA1X26WsBPnjV4Af-DGQMFVh-kN56TCw_

but I want it like this:
ceo4f4bed3b29d94c1386761ed65a1fa68c4a5fd82e7495164ebf445

@ManOnMission I’m not using ios yet, but this seems related to your problem:

Also, if you are using version 2.x of the plugin, you need to add GoogleService-Info.plist to your project:

(The version 2.x of the plugin seems to work only with iOS >= 9)

Then try to send a notification to FCM with the received token.

I want to share my experience with using it as there a couple of hacks needed to get it to play nice. I’m going to try and summarize what is needed to get it to work with Ionic below.

CSS

/* allows the bar-footer to be elastic /*
/* optionally set a max-height */
/* maxlength on the textarea will prevent /*
/* it from getting too large also */
.bar-footer {
  overflow: visible !important;

@ankushagg93 please can you send ionic 3 code for push notification and setting alias for particular device.