OS1 Services
Messaging and Mobile Push Noti...
Mobile Push Notifications
7 min
overview developers can use the mobile push notifications apis to register their android or ios applications and receive push notifications these apis allow for customization of message formats with text, images, and action buttons additionally, developers can specify delivery options such as priority, expiration time, and device targeting the apis are compatible with both android and ios platforms, which enables developers to send notifications to users across different devices from a unified interface integration flow register a mobile application in firebase cloud messaging (fcm) register the notification configuration in the notification service send mobile push notifications step 1 register a mobile app in fcm before configuring a mobile app for the notification service, call https //docs getos1 com/reference/register new app to add fcm app credentials, including the project id, client email, and private key to the secure data storage (sds) service vault mobile app registration uses the following parameters true left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type this is required below is a sample request for registering a mobile app on the android platform register mobile app { "name" "my app", "appplatform" "android", "appid" "com example myapp", "enablenotification" true, "accountconfig" { "android" { "projectid" "my project id", "clientemail" "client email\@example com", "privatekey" "private key 123" } } } upon success, the response will include a unique id for the registered app step 2 register the notification configuration call https //docs getos1 com/reference/add app notification configuration to set the default configuration for your notifications on the android or ios platform each platform has it's own configuration options true 213left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type true 173left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type the sample requests below registers app notification configurations for android and ios android config { "name" "my android app", "appplatform" "android", "appid" "com example myandroidapp", "enablenotification" true, "accountconfig" { "android" { "projectid" "android project id", "clientemail" "android client email\@example com", "privatekey" "android private key 123" } }, "androidconfig" { "collapsekey" "my collapse key", "priority" "high", "ttl" 3600000, "restrictedpackagename" "com example myandroidapp", "icon" "ic notification", "color" "#ff0000", "sound" "default", "tag" "my notification tag", "clickaction" "open activity 1", "bodylockey" "notification body", "bodylocargs" \[ "arg1", "arg2" ], "titlelockey" "notification title", "titlelocargs" \[ "arg1", "arg2" ], "channelid" "channel id 1", "ticker" "new notification", "sticky" false, "eventtimestamp" "2023 06 20t10 00 00z", "localonly" false, "notificationpriority" "default", "defaultsound" true, "defaultvibratetimings" true, "defaultlightsettings" true, "vibratetimingsmillis" \[ 1000, 500, 1000, 500 ], "visibility" "public", "notificationcount" 3, "imageurl" "https //example com/image jpg" } } ios config { "name" "my ios app", "appplatform" "ios", "appid" "com example myiosapp", "enablenotification" true, "accountconfig" { "ios" { "projectid" "ios project id", "clientemail" "ios client email\@example com", "privatekey" "ios private key 123" } }, "iosconfig" { "priority" 10, "sound" "default", "volume" 1 0, "criticalsound" true, "imageurl" "https //example com/image jpg" } } upon success, the response will include a unique id for the registered notification configuration step 3 send mobile push notifications call https //docs getos1 com/reference/ aso send notifications to send mobile push notifications for the android or ios platform this call supports multiple notifications in a single api call, and notifications to multiple devices the following examples show the following sending multiple notifications to a single device sending notifications to multiple devices multiple notifications to a single device { "notifications" \[ { "appplatform" "android", "devicetokens" \[ "android device token" ], "body" { "title" "android notification 1", "body" "this is the first notification message for the android device ", "data" { "key1" "value1", "key2" "value2" } }, "androidconfig" { "collapsekey" "android collapse key 1", "priority" "high", "ttl" 3600000, "notificationpriority" "default", "defaultsound" true, "defaultvibratetimings" true } }, { "appplatform" "android", "devicetokens" \[ "android device token" ], "body" { "title" "android notification 2", "body" "this is the second notification message for the android device ", "data" { "key3" "value3", "key4" "value4" } }, "androidconfig" { "collapsekey" "android collapse key 2", "priority" "normal", "ttl" 5400000, "notificationpriority" "high", "defaultsound" false, "defaultvibratetimings" false } } ] } notification to multiple devices { "notifications" \[ { "appplatform" "android", "devicetokens" \[ "android device token 1", "android device token 2" ], "body" { "title" "new android notification", "body" "this is a sample notification message for android devices ", "data" { "key1" "value1", "key2" "value2" } }, "androidconfig" { "collapsekey" "android collapse key", "priority" "high", "ttl" 3600000, "notificationpriority" "default", "defaultsound" true, "defaultvibratetimings" true } }, { "appplatform" "ios", "devicetokens" \[ "ios device token 1", "ios device token 2" ], "body" { "title" "new ios notification", "body" "this is a sample notification message for ios devices ", "data" { "key1" "value1", "key2" "value2" } }, "iosconfig" { "priority" 10, "sound" "default", "volume" 1 0, "criticalsound" true } } ] } in this example, the request body includes the following properties notifications an array of notification objects for the same device android notification 1 appplatform the platform of the app (in this case, "android") devicetokens an array containing a single device token for the android device body an object containing the notification content for the first notification androidconfig an object containing android specific notification configuration for the first notification android notification 2 appplatform the platform of the app (in this case, "android") devicetokens an array containing the same device token for the android device body an object containing the notification content for the second notification androidconfig an object containing android specific notification configuration for the second notification this request sends multiple notifications to a single android device using different notification content and android specific configuration options for each notification note make sure to replace the android device token with the actual device token of the android device you want to send the notifications to in this example, the request body includes the following properties notifications an array of notification objects for different platforms android notification appplatform the platform of the app (in this case, "android") devicetokens an array of device tokens for android devices body an object containing the notification content for android devices androidconfig an object containing android specific notification configuration ios notification appplatform the platform of the app (in this case, "ios") devicetokens an array of device tokens for ios devices body an object containing the notification content for ios devices iosconfig an object containing ios specific notification configuration this request sends notifications to multiple devices across different platforms (android and ios) using the provided notification content and platform specific configuration options note make sure to replace the tokens arrays with the actual device tokens you want to send the notifications to for each platform upon success, the response includes an accepted message parameter