Create Firebase Notification through API

Fergal Powell6 years ago

Hello, is it possible to create a notification object of type mobile or firebase through the api? From reading the documentation, only type sms, web and mail can be set through the API. Is there another option not listed in the documentation for mobile or firebase?

Or is it possible to link a previously created notification object with a newly created user through the api. The documentation for the Permission api states that only user, device, geofence, calendar, attribute, driver and managed user objects can be mapped together. Can a notification be mapped to a user also?

Ernesto Vallejo6 years ago

It is possible.

Fergal Powell6 years ago

Hi Ernesto,

Which is possible? To create notification object with notificator type mobile from the api or link previously created notification to a user? Or both?

Thanks,
Fergal

Anton Tananaev6 years ago

Anything you can do in the web app, you can do via API. Web app uses exactly the same API.

Fergal Powell6 years ago

Thanks for replies, That's good news. I've had a look through the Web app source code however I am struggling to find where the request is made to the API to create a notification. Can you point me in the right direction?

Anton Tananaev6 years ago

Just use browser developer tools to see API requests.

Fergal Powell6 years ago

Okay. that was very useful advice, thanks. From looking at API requests in developer tools , I can see that the request payload should look like this

{
    "id":-2,
    "type":"geofenceEnter",
    "always":true,
    "notificators":"firebase,web",
    "calendarId":0
}

When id is set to -2 does this mean that the server should assign a new id to it automatically?

I can see that the request URL should be: https://www.myipaddress.com/api/notifications?_dc=15526669311120. What is the query parameter at the end of the request? Will I need to specify that when making a request?

Anton Tananaev6 years ago

Ignore _dc parameter.

Fergal Powell6 years ago

Okay and I can see that it's possible to link user with notification by posting to this url "/api/permissions" with the following request payload:

{
    "userId":96,
    "notificationId":1
}

Thanks for your help, will begin implementing it today.