PeterStaev / nativescript-azure-mobile-apps

:cloud: NativeScript plugin for working with Microsoft Azure Mobile Apps services
Apache License 2.0
30 stars 10 forks source link

Push Notifications not working on Android #35

Closed tylerablake closed 5 years ago

tylerablake commented 5 years ago

Hi,

I am able to send notifications to my device from GCM manually so I know the device token I am using to register to Azure with the plugin is correct. I get a 'Azure Register OK!' response with the installationId but don't receive any notifications from Azure. Azure test message says it was sent successfully and there are no errors in the metrics.

Any ideas on what I might be missing? I've tried to make my AndroidManifest file match the one in the demo. I have minSDK set to 19, etc.

Thank you for your help!

PeterStaev commented 5 years ago

@tylerablake , have you set up Azure correctly with your GCM/FCM settings?

tylerablake commented 5 years ago

Hi @PeterStaev,

I got it to work, it was an invalid format from Azure's test page.

With GCM being deprecated it looks like FCM wants to wrap the push notifications inside of a 'message' object. Do you know if that work with this plugin or will that only affect people using FCM as a hub to send their push notifications?

Thanks!

PeterStaev commented 5 years ago

Well not sure, I'm using the following as push templates for one of my projects:

const pushTemplates = {};
pushTemplates[platformNames.android] = JSON.stringify({
    data: {
        title: "$(title)",
        message: "$(message)",
    },
    notification: {
        title: "$(title)",
        text: "$(message)",
    },
});
pushTemplates[platformNames.ios] = JSON.stringify({
    aps: {
        alert: {
            title: "$(title)",
            body: "$(message)",
            sound: "default",
        },
        badge: "#(badgeCount)",
    },
});

Because of the depreciation I'm planning to update the plugin soon so it can continue to work after the stop of the GCM services in May. So will see if there are any differences then.