Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nativescript-urban-airship

Package Overview
Dependencies
Maintainers
7
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nativescript-urban-airship

Urban Airship plugin for NativeScript.

  • 7.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
increased by36.36%
Maintainers
7
Weekly downloads
 
Created
Source

NativeScript plugin for Urban Airship

npm version

This is a plugin to use the Urban Airship SDK (Android v15.0.0, iOS v15.0.1) with NativeScript.
For iOS this plugin uses APNS and for Android it uses FCM.

Requirements

  • Xcode 12.x
  • Android SDK 29
  • NativeScript CLI 7.x
  • Urban Airship account

Installation

Run the following command from the root of your project:

npm install nativescript-urban-airship

Setup

First create a file with all your Urban Airship setting (example).

Android
  1. Create a custom native android.app.Application in your app folder (example) that calls startUp() with your settings in the onCreate():

    public onCreate(): void {
        super.onCreate();
    
        NsUrbanAirship.getInstance().startUp(urbanAirshipSettings, this);
    }
    

    Use that custom application in the application tag in your AndroidManifest.xml (example).

  2. Place your google-services.json in your App_Resources/Android folder. This json file can be created using the setup of FCM.

  3. Copy the hooks firebase-adjust-gradle.js and firebase-copy-google-services.js from our demo app to the after-prepare folder of your app.

  4. Specify the right applicationId in your app's app.gradle (example).

  5. Specify the right id in your app's package.json.

iOS

Create a custom UIApplicationDelegate in your app folder (example) that calls startUp() with your settings in the applicationDidFinishLaunchingWithOptions():

applicationDidFinishLaunchingWithOptions(application: UIApplication, launchOptions: NSDictionary<string, any>): boolean {
    NsUrbanAirship.getInstance().startUp(urbanAirshipSettings, null);
    return true;
};

Import that custom UIApplicationDelegate in your app.ts (example).

Swift Version

Since version 6.0 of the plugin, if the project does not already include it, it is necessary to raise the Swift version to 5.0 by adding the following line to your Podfile.

    config.build_settings['SWIFT_VERSION'] = '5.0'
Styling the Preference Center

In order to style the Preference Center on iOS, it is necesssary to create a AirshipPreferenceCenterStyle.plist file and populate it according to the information that can be found here. NOTE: At the time of writing this, all the possible parameters have not been listed on the page mentioned and can be found here.

Known Issues

When using webpack, calling startUp() on Android in a custom native android.app.Application is not working, in that case it is better to call the native function instead of startUp():

public onCreate(): void {
    super.onCreate();

    const options = new com.urbanairship.AirshipConfigOptions.Builder()
        .setDevelopmentAppKey(urbanAirshipSettings.developmentAppKey)
        .setDevelopmentAppSecret(urbanAirshipSettings.developmentAppSecret)
        .setProductionAppKey(urbanAirshipSettings.productionAppKey)
        .setProductionAppSecret(urbanAirshipSettings.productionAppSecret)
        .setInProduction(urbanAirshipSettings.inProduction)
        .build();

    com.urbanairship.UAirship.takeOff(this, options);
}

Optional functions

Setting Named User Id

To register a named user id call registerUser().

NsUrbanairship.getInstance().registerUser('MY_NEW_USER_ID');
Removing Named User Id

To remove a named user id call unRegisterUser().

NsUrbanairship.getInstance().unRegisterUser();
Enabling User Notifications

To set user notifications to enabled call notificationOptIn().

NsUrbanairship.getInstance().notificationOptIn();
Disabling User Notifications

To set user notifications to disabled call notificationOptOut().

NsUrbanairship.getInstance().notificationOptOut();
Getting Enabled User Notifications

To get the status of enabled push notifications call isOptIn(), this will return true or false.

NsUrbanairship.getInstance().isOptIn();
Getting Channel ID

To get the channel ID call getChannelID(), this will return a string.

NsUrbanairship.getInstance().getChannelID();
Getting Registration Token

To get the registration token (APNS token for iOS and FCM token for Android) call getRegistrationToken(), this will return a string.

NsUrbanairship.getInstance().getRegistrationToken();
Resetting Badge Count (iOS only)

To reset the badge count call resetBadgeCount().

NsUrbanairship.getInstance().resetBadgeCount();
Opening Preference Center

To open the preference center call openPreferenceCenter().

NsUrbanairship.getInstance().openPreferenceCenter('PREFERENCE_CENTER_ID');

Keywords

FAQs

Package last updated on 18 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc