Push Notifications¶
Aurena Native apps are sent push notifications via a Notification Hub in Azure. The details of this hub can be defined in the.app file as follows:
settings {
notificationhub {
connectionstring "Endpoint=sb://...";
path "[NotificationHubName]";
}
}
The connectionstring
property should be the full access endpoint address for your hub, while the path
property should be set to the name of your notification hub. In theory, deploying the app will then set the NOTIFICATION_HUB_URL
and NOTIFICATION_HUB_PATH
parameters for the app in that environment. However, if the application parameters already exist on your environment then these will not be overwritten - the app must be deleted from the environment or those parameters must be deleted out of the database (not just out of the Application Parameters screen in EE) before redeploying.
Alternatively, the NOTIFICATION_HUB_URL
and NOTIFICATION_HUB_PATH
can be set manually in the Application Parameters screen in the environment's EE client.
Notification Types¶
Server Framework sends default "silent" push notifications to devices whenever data becomes available in the out queue. These are not visible to the end user, but will trigger a sync in the client if it is currently running.
It is also possible to define custom push alerts in the app model, allowing the user to get visible messages on certain events.
Defining Custom Notifications¶
App model has a new section called notifications
which defines custom alert messages. They are grouped by entity and each entity would have three different message groups depending on the state of the record.
- on new: New row is created in the server.
- on modified: Existing row has been modified in the server.
- on removed: Existing row has been removed
Also each group would have two different types of messages depends on the volume of data.
- singlerecord: Single record found in this batch.
- multirecord: Mutiple records found in this batch.
Marble¶
notifications {
entity TstCompany {
on new {
singlerecord {
message = "New Company '${Company}' created - test message";
}
multirecord {
message = "Mutiple new Companies created - test message";
}
}
on modified {
singlerecord {
message = "Company '${Company}' updated - test message";
}
multirecord {
message = "Mutiple Companies updated - test message";
}
}
on removed {
singlerecord {
message = "Company '${Company}' deleted - test message";
}
multirecord {
message = "Mutiple Companies deleted - test message";
}
}
}
}
@alert info Those messages will be translatable in the future in the same way as how other contents are translated in IFS Cloud. @end
Executing a command when a notification is tapped¶
It is possible to execute a command defined in the client file when the user taps on a notification. This is done in the app file within the syntax given above by using the on click
keyword. Use the command
keyword to define the "fully-qualified" command name, and the variable
keyword to define the variables that need to be passed to the command when it executes. The command will execute within the context defined in the fully-qualified name (page/card).
The fully-qualified command name is given as follows: <card/page name>_<command name>
Examples: WorkOrderCard_SetAccepted
, WorkOrderDetail_GoToTimeReports
The two parameters passed into the variable
keyword would be the name of the variable in the command, and which field of the current record that will provide the value for that variable.
Examples: variable(CompanyIdVar, CompanyId)
There are some limitations in the current implementation - Only one command may be used, defining more than one command in the app file will lead to an undesirable state. - A delay will be on Android/iOS when the command executes, because a sync needs to happen prior. - Constants cannot be passed as variables (such as variable(Var1, 42)
or variable(Var2, "test")
). - The command will not execute until the user logs into the app. - It is not recommended to use commands for multirecord
push messages.
Example syntax:
notifications {
entity TstCompany {
on new {
singlerecord {
message = "New Company '${Company}' created";
on click {
command CompanyCard_CompanyCard_Details;
variable(Company, Company);
}
}
}
}
}
Send Notification messages programmatically from the back office¶
You can also send specific messages to the user or broadcast a message to all users via backend business logic. The plsql LU Mobile_Push_Services_SYS
have supporting methods to do this.
Mobile_Push_Services_SYS¶
//Broadcast Push Notification to all devices of given app
PROCEDURE Broadcast_Notification(
message_ IN VARCHAR2,
app_name_ IN VARCHAR2);
//Send Push Notification to specific user device.
//If you do not set the device_id parameter, then FW will send the message to all active devices own by this user_id.
PROCEDURE Send_Notification(
message_ IN VARCHAR2,
app_name_ IN VARCHAR2,
user_id_ IN VARCHAR2,
device_id_ IN VARCHAR2 DEFAULT NULL);
Send Notification messages from Aurena client¶
You can also send specific messages to a user by going to Solution Manager > Aurena Native Apps > Administration > Installed Apps Devices. Filter by user Id/App Name/Device Id with State = Active to find your device, click on the 3 dots icon on the row and select "Send Notification". You can then type a message and send it.
iOS Push notification example with payload¶
"aps": {
"alert": {
"body": "Test Push Notification"
},
"badge": 5
}
Send Push Notification to iOS simulator¶
To be able to send a push notification to an iOS simulator you need to create a ".apns" file, the text inside needs to contain a Simulator Target Bundle which should match the bundle id of the app for the app needed to receive the notification and it should contain a title and a body to be able to see it in the device.
Once the file has been created and the contents added, the file needs to be dragged into the simulator (this can only be done in the Mac as you cannot drag files into the iOS simulator to Windows option). Once dragged you will see the notification in the simulator on the top bar, this needs to be tapped to be able to trigger the notification into the app.
iOS simulator Push notification example¶
{
"Simulator Target Bundle": "com.example.TestApp",
"aps": {
"content-available": 1,
"alert": {
"title": "Push Notification title example",
"body": "Push Notification body example"
},
"badge": 5
},
}