npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nativescript/firebase-in-app-messaging

v3.3.1

Published

NativeScript Firebase - In App Messaging

Downloads

946

Readme

@nativescript/firebase-in-app-messaging

Contents

Intro

This plugin allows you to use the Firebase In-App Messaging SDK in your NativeScript app.

image

Set up your app for Firebase

You need to set up your app for Firebase before you can use the Firebase in-app messaging. To set up and initialize Firebase for your NativeScript app, follow the instructions on the documentation of the @nativescript/firebase-core plugin.

Add the Firebase In-App Messaging SDK to your app

To add the Firebase In-App Messaging SDK to your app follow these steps:

  1. Install the @nativescript/firebase-in-app-messaging plugin by running the following command in the root directory of your project.
npm install @nativescript/firebase-in-app-messaging
  1. Add the SDK by importing the @nativescript/firebase-in-app-messaging module in your app's main file (e.g. app.ts or main.ts).
import '@nativescript/firebase-in-app-messaging';

Firebase In-App Messaging limitations

According to a github issue https://github.com/firebase/firebase-ios-sdk/issues/4768, Firebase In-App Messaging allows only 1 campaign per day on app foreground or app launch. This limit is to prevent you from accidentally overwhelming your users with non-contextually appropriate messages. However, if you use contextual triggers (for example Analytics events or programmatically triggered in-app-messaging campaigns), there is no daily rate limit.

Create message campaigns

To create a message campaign, go to the In-App Messaging page in the Firebase Console and follow the instructions there. You can create campaigns and customize elements such as Image, Banner, Modal & Cards to appear on predefined events (e.g. purchase).

Any published campaigns from the Firebase Console are automatically handled and displayed on your user's device.

Control messages display

To control whether to display messages or not, set the isMessagesDisplaySuppressed property of the InAppMessaging instance to true or false. The InAppMessaging instance is returneb calling the inAppMessaging() on the FirebaseApp instance. By default, isMessagesDisplaySuppressed is set to false which means messages will be displayed.

import { firebase } from '@nativescript/firebase-core';
import '@nativescript/firebase-in-app-messaging';

async function bootstrap() {
  firebase().inAppMessaging().isMessagesDisplaySuppressed = true;
}

async function onSetup(user) {
  await setupUser(user);
  // Allow user to receive messages now setup is complete
  firebase().inAppMessaging().isMessagesDisplaySuppressed = false;
}

Note: The suppressed state is not persisted between restarts, so ensure it is called as early as possible ideally in the app bootstrapping file(app.ts or main.ts).

Trigger contextual messages

To trigger contextual messages, call the triggerEvent() method of the InAppMessaging instance with the event name as a parameter. This triggers the display of any messages that are configured on the Firebase Console.

import { firebase } from '@nativescript/firebase-core';

firebase().inAppMessaging().triggerEvent('purchase');

API

InAppMessaging class

app

inAppMessagingApp = firebase().inAppMessaging().app;

The app property returns the FirebaseApp instance that the current InAppMessaging instance is associated with.


isAutomaticDataCollectionEnabled

firebase().inAppMessaging().isAutomaticDataCollectionEnabled = true;

For the description of this property, see isAutomaticDataCollectionEnabled on the Firebase documentation.


isMessagesDisplaySuppressed

firebase().inAppMessaging().isMessagesDisplaySuppressed = true;
// or
firebase().inAppMessaging().isMessagesDisplaySuppressed = false;

For the description of this property, see areMessagesSuppressed on the Firebase documentation.


triggerEvent()

firebase().inAppMessaging().triggerEvent(eventId);

| Parameter | Type | Description | | --- | --- | --- | | eventId | string | The name of the event to trigger.

For the description of this method, see triggerEvent on the Firebase documentation.


License

Apache License Version 2.0