Added in plugin version 8.2.0
Engage active app users with contextual messages.
Check out the (code of the) Vue demo!
To add this feature to your project, either:
- Remove
firebase.nativescript.json
from the root of the project and runnpm i
, or - Edit that file and add
"in_app_messaging": true
.
In both cases, remove the /platforms
folder afterwards so the required native library will be added upon the next build.
There's nothing you have to do code-wise if you only want to display messages. If you want to capture a 'button clicked' event however, read on.
import { inappmessaging } from "nativescript-plugin-firebase/inappmessaging";
inappmessaging.onMessageClicked(message => {
console.log("Clicked a button for Campaign: " + message.campaignName);
});
You can also get notified if a message is being shown to a user:
import { inappmessaging } from "nativescript-plugin-firebase/inappmessaging";
inappmessaging.onMessageImpression(message => {
console.log("A message belonging to this campaign is being shown: " + message.campaignName);
});
Trigger in-app messages programmatically.
Firebase In-App Messaging by default allows you to trigger in-app messages with Google Analytics for Firebase events, with no additional integration. You can also manually trigger events programmatically with the Firebase In-App Messaging SDK’s programmatic triggers.
In the In-App Messaging campaign composer, create a new campaign or select an existing campaign, and in the Scheduling step of the composer workflow, note the event ID of a newly-created or existing messaging event. Once noted, instrument your app to trigger the event by its ID.
import { inappmessaging } from "nativescript-plugin-firebase/inappmessaging";
const eventName = "myEvent";
inappmessaging.triggerEvent(eventName);