...
Create a new ruleset User Attribute > Battery Level to be applied on SystemWide Offer.
The new ruleset will check the battery level according to the parameter inputted;
The
User Attributes
property,Battery Level
will be checked when the user starts the app and then, every 2 minutes. This property will only be checked if at least one of the Systemwide Offers available has the Battery Level rule within its UserAttributes rules.
If the user’s battery level hits the parameter, an offer will be available on their Offers page, only App;
No latency between when the guest triggers the offer and when it appears in the App;
Display this offer on Kiosk, we need a development on our side and Acrelec also needs to have a development. So, the recommendation is go live only on App because the users receive a In-App notification and they can redeem the offer right-way in the App;
The offer will be available until the user battery becomes above the parameter;
To run the be able to run the battery level rule evaluation when the app is in background we're introducing
@capacitor/background-runner
package. This enables us to run JS scripts in the background for both Android and iOS:We will schedule the background job successfully user first have to start the app.
When the app starts in the foreground, we persist all battery level rules from offers to be able to access this data later in the background. For user data we're accessing existing user data stored under
RBI_USER
key.When the App enters the background, we schedule the background job. Currently, it's configured to run every 5 minutes10 minutes for iOS or 15 minutes for Android, however due to platform level battery optimizations, it's not guaranteed that the script will always run (see the docs for more details). In the script we initially check if:
User is signed in
Battery level rules are stored
When these two conditions are met, we then evaluate the battery level rule with the current device battery level, in case when the battery level has changed enough to enter/leave the configured battery threshold, we will send a local notification when the conditions are met. When the guest taps the notification it opens the Offers Page in the App and the mParticle event will be sent from foreground. This would be safer in terms of duplicating events from foreground/background.
Risks:
Platform level battery optimizations:
There are no guarantees the background job will ever run, especially when the battery level is low;
Need to take into consideration iOS and Android battery optimizations feature which they might be kill our background job.
We should use threshold above 20%. For instance 30%, based on iOS platform usually starts their battery optimizations function in 20%.
...
# | Scenarios | Test Steps | Test Result | Notes |
---|---|---|---|---|
1 | The guest signs-in and it is navigating in the app and his phone has the battery level > 30%, so no special offer will be triggered. |
| ||
2 | The guest not signs-in and it is navigating in the app and his phone has the battery level <= 30% |
| ||
3 | The guest signs-in and it is navigating in the app and his phone has the battery level <= 30%. The guest will receive an In-App message or the guest can access directly the Offers Page. The guest does not redeem the offer. The guest charges their phone and the offer will disappear from the Offers Page. |
| ||
4 | The guest signs-in and it is navigating in the app and his phone has the battery level <= 30%. The guest will receive an In-App message or the guest can access directly the Offers Page. The guest redeem the offer. In the same day, the guest charges his phone to 100% and opens the app again. The special offer will be not show in the app because the guest already redeem the offer in the same day. |
| ||
5 | The guest signs-in, opens the app, navigating and move to another app. BK app is running in the background and the battery level is still checking by our app each 10 minutes for iOS and 15 minutes for Android. The guest has the battery level > 30%, so no local notification will be triggered and no special offer will be available on the Offers Page. |
| ||
7 | The guest signs-in, opens the app, navigating and move to another app. BK app is running in the background and the battery level is still checking by our app each 10 minutes for iOS and 15 minutes for Android. The guest has the battery level <= 30%. The local notification will be triggered and when the guest clicks on the notification, we will redirect him to the Offers Page. The special offer will be available on the Offers Page. The guest does not redeem the offer. The guest charges their phone and the offer will disappear from the Offers Page. |
| ||
8 | The guest signs-in and it is navigating in the app and his phone has the battery level <= 30%. The local notification will be triggered and when the guest clicks on the notification, we will redirect him to the Offers Page. The special offer will be available on the Offers Page. The guest redeem the offer. In the same day, the guest charges his phone to 100%, the local notification will be not triggered and no special offer will be available on the Offers Page. |
|