Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit fe5c0de

Browse files
Add support for In-App Messaging event triggers #1285
1 parent b006682 commit fe5c0de

File tree

7 files changed

+34
-10
lines changed

7 files changed

+34
-10
lines changed

demo-vue/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
"nativescript": {
88
"id": "org.nativescript.firebasedemo.firestore",
99
"tns-ios": {
10-
"version": "5.0.0"
10+
"version": "6.0.1"
1111
},
1212
"tns-android": {
13-
"version": "5.0.0"
13+
"version": "6.0.0"
1414
}
1515
},
1616
"dependencies": {
1717
"nativescript-plugin-firebase": "file:../publish/package/nativescript-plugin-firebase-9.1.0.tgz",
18-
"nativescript-theme-core": "^1.0.4",
19-
"nativescript-vue": "^2.0.0",
20-
"tns-core-modules": "^5.0.2"
18+
"nativescript-theme-core": "~1.0.6",
19+
"nativescript-vue": "~2.4.0",
20+
"tns-core-modules": "~6.0.0"
2121
},
2222
"devDependencies": {
2323
"@babel/core": "^7.0.0",

docs/IN_APP_MESSAGING.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,17 @@ inappmessaging.onMessageImpression(message => {
4242
console.log("A message belonging to this campaign is being shown: " + message.campaignName);
4343
});
4444
```
45+
46+
### `triggerEvent`
47+
Trigger in-app messages programmatically.
48+
49+
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.
50+
51+
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.
52+
53+
```typescript
54+
import { inappmessaging } from "nativescript-plugin-firebase/inappmessaging";
55+
56+
const eventName = "myEvent";
57+
inappmessaging.triggerEvent(eventName);
58+
```

src/functions/functions.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
export declare type HttpsCallable<I, O> = ( callableData: I ) => Promise<O>;
1+
export declare type HttpsCallable<I, O> = (callableData: I) => Promise<O>;
2+
23
export declare function httpsCallable<I = {}, O = {}>(functionName: string): HttpsCallable<I, O>;

src/inappmessaging/inappmessaging.android.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ export function onMessageImpression(callback: (data: OnMessageImpressionCallback
2323

2424
com.google.firebase.inappmessaging.FirebaseInAppMessaging.getInstance().addImpressionListener(listener)
2525
}
26+
27+
export function triggerEvent(eventName: string): void {
28+
com.google.firebase.inappmessaging.FirebaseInAppMessaging.getInstance().triggerEvent(eventName);
29+
}

src/inappmessaging/inappmessaging.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ export interface OnMessageClickedCallbackData {
1010

1111
export declare function onMessageImpression(callback: (data: OnMessageImpressionCallbackData) => void): void;
1212

13-
export declare function onMessageClicked(callback: (data: OnMessageClickedCallbackData) => void): void;
13+
export declare function onMessageClicked(callback: (data: OnMessageClickedCallbackData) => void): void;
14+
15+
export declare function triggerEvent(eventName: string): void;

src/inappmessaging/inappmessaging.ios.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ export function onMessageImpression(callback: (data: OnMessageImpressionCallback
1212
_firInAppMessagingDisplayDelegate.setOnMessageImpressionCallback(callback);
1313
}
1414

15+
export function triggerEvent(eventName: string): void {
16+
FIRInAppMessaging.inAppMessaging().triggerEvent(eventName);
17+
}
18+
1519
function ensureDelegate(): void {
1620
if (!_firInAppMessagingDisplayDelegate) {
1721
FIRInAppMessaging.inAppMessaging().delegate = _firInAppMessagingDisplayDelegate = FIRInAppMessagingDisplayDelegateImpl.new();

src/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,12 @@
4646
"demo-push.ios.release": "npm run preparedemo-push && cd ../demo-push && tns build ios --release --for-device",
4747
"demo-push.ios.eddy.iphoneX": "npm run preparedemo-push && cd ../demo-push && tns run ios --device a4cbb499e279054b55c206528f8510ff7fbf20c8",
4848
"demo.android": "npm run preparedemo && cd ../demo && rimraf platforms/android && tns run android",
49-
"demo.android.linked": "npm run tsc && cd ../demo && tns run android --syncAllFiles",
5049
"demo-ng.android": "npm run preparedemo-ng && cd ../demo-ng && tns run android",
5150
"demo-ng.android.build": "npm run preparedemo-ng && cd ../demo-ng && tns build android",
5251
"demo-ng.android.bundled": "npm run preparedemo-ng && cd ../demo-ng && tns run android --bundle",
5352
"demo-push.android": "npm run preparedemo-push && cd ../demo-push && tns run android",
54-
"demo-vue.ios": "npm run preparedemo-vue && cd ../demo-vue && tns run ios --bundle --syncAllFiles",
55-
"demo-vue.android": "npm run preparedemo-vue && cd ../demo-vue && tns run android --bundle --syncAllFiles",
53+
"demo-vue.ios": "npm run preparedemo-vue && cd ../demo-vue && tns run ios --bundle",
54+
"demo-vue.android": "npm run preparedemo-vue && cd ../demo-vue && tns run android --bundle",
5655
"test": "npm run tslint && npm run tslint.demo && cd ../demo && tns build ios && tns build android",
5756
"test.ios": "cd ../demo && tns test ios --emulator",
5857
"test.ios.device": "cd ../demo && tns platform remove ios && tns test ios",

0 commit comments

Comments
 (0)