{"id":21882389,"url":"https://github.com/essent/nativescript-urban-airship","last_synced_at":"2025-04-15T05:55:01.980Z","repository":{"id":16064767,"uuid":"79216869","full_name":"Essent/nativescript-urban-airship","owner":"Essent","description":"Urban airship plugin interface for NativeScript","archived":false,"fork":false,"pushed_at":"2022-08-18T12:03:12.000Z","size":2653,"stargazers_count":6,"open_issues_count":8,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-15T05:54:57.224Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Essent.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-17T10:35:50.000Z","updated_at":"2021-12-21T11:53:36.000Z","dependencies_parsed_at":"2022-08-29T07:42:08.336Z","dependency_job_id":null,"html_url":"https://github.com/Essent/nativescript-urban-airship","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Essent%2Fnativescript-urban-airship","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Essent%2Fnativescript-urban-airship/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Essent%2Fnativescript-urban-airship/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Essent%2Fnativescript-urban-airship/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Essent","download_url":"https://codeload.github.com/Essent/nativescript-urban-airship/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249016320,"owners_count":21198832,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-28T09:28:48.951Z","updated_at":"2025-04-15T05:55:01.959Z","avatar_url":"https://github.com/Essent.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NativeScript plugin for Urban Airship\n[![npm version](https://badge.fury.io/js/nativescript-urban-airship.svg)](https://www.npmjs.com/package/nativescript-urban-airship)\n\nThis is a plugin to use the [Urban Airship](https://www.urbanairship.com/) SDK (Android v15.0.0, iOS v15.0.1) with NativeScript.  \nFor iOS this plugin uses APNS and for Android it uses FCM.\n\n## Requirements\n* Xcode 12.x\n* Android SDK 29\n* NativeScript CLI 7.x\n* Urban Airship account\n\n## Installation\nRun the following command from the root of your project:\n\n```console\nnpm install nativescript-urban-airship\n```\n\n### Setup\nFirst create a file with all your Urban Airship setting ([example](./demo/app/urbanAirshipSettings.ts)).\n\n#### Android\n1. Create a custom native android.app.Application in your app folder ([example](./demo/app/application.android.ts)) that calls `startUp()` with your settings in the `onCreate()`:\n    ```ts\n    public onCreate(): void {\n        super.onCreate();\n    \n        NsUrbanAirship.getInstance().startUp(urbanAirshipSettings, this);\n    }\n    ```\n    Use that custom application in the application tag in your `AndroidManifest.xml` ([example](./demo/app/App_Resources/Android/src/main/AndroidManifest.xml#L22)).\n\n2. Place your `google-services.json` in your `App_Resources/Android` folder. This json file can be created using the [setup of FCM](https://firebase.google.com/docs/android/setup).\n\n3. Copy the hooks [firebase-adjust-gradle.js](./demo/hooks/after-prepare/firebase-adjust-gradle.js) and [firebase-copy-google-services.js](./demo/hooks/after-prepare/firebase-copy-google-services.js) from our demo app to the `after-prepare` folder of your app.\n\n4. Specify the right `applicationId` in your app's `app.gradle` ([example](./demo/app/App_Resources/Android/app.gradle#L10)).\n\n5. Specify the right `id` in your app's `package.json`.\n\n#### iOS\nCreate a custom UIApplicationDelegate in your app folder ([example](./demo/app/custom.delegate.ts)) that calls `startUp()` with your settings in the `applicationDidFinishLaunchingWithOptions()`:\n```ts\napplicationDidFinishLaunchingWithOptions(application: UIApplication, launchOptions: NSDictionary\u003cstring, any\u003e): boolean {\n    NsUrbanAirship.getInstance().startUp(urbanAirshipSettings, null);\n    return true;\n};\n```\nImport that custom UIApplicationDelegate in your `app.ts` ([example](./demo/app/app.ts)).\n\n#### Swift Version\nSince 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.\n```ts\n    config.build_settings['SWIFT_VERSION'] = '5.0'\n```\n\n#### Styling the Preference Center\nIn 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](https://docs.airship.com/platform/ios/preference-center/).\nNOTE: At the time of writing this, all the possible parameters have not been listed on the page mentioned and can be found [here](https://github.com/urbanairship/ios-library/blob/main/Airship/AirshipPreferenceCenter/Source/PreferenceCenterStyle.swift).\n\n### Known Issues\nWhen 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()`:\n```ts\npublic onCreate(): void {\n    super.onCreate();\n\n    const options = new com.urbanairship.AirshipConfigOptions.Builder()\n        .setDevelopmentAppKey(urbanAirshipSettings.developmentAppKey)\n        .setDevelopmentAppSecret(urbanAirshipSettings.developmentAppSecret)\n        .setProductionAppKey(urbanAirshipSettings.productionAppKey)\n        .setProductionAppSecret(urbanAirshipSettings.productionAppSecret)\n        .setInProduction(urbanAirshipSettings.inProduction)\n        .build();\n\n    com.urbanairship.UAirship.takeOff(this, options);\n}\n```\n\n### Optional functions\n\n#### Setting Named User Id\nTo register a named user id call `registerUser()`.\n\n```ts\nNsUrbanairship.getInstance().registerUser('MY_NEW_USER_ID');\n```\n\n#### Removing Named User Id\nTo remove a named user id call `unRegisterUser()`.\n\n```ts\nNsUrbanairship.getInstance().unRegisterUser();\n```\n\n#### Enabling User Notifications\nTo set user notifications to enabled call `notificationOptIn()`.\n\n```ts\nNsUrbanairship.getInstance().notificationOptIn();\n```\n\n#### Disabling User Notifications\nTo set user notifications to disabled call `notificationOptOut()`.\n\n```ts\nNsUrbanairship.getInstance().notificationOptOut();\n```\n\n#### Getting Enabled User Notifications\nTo get the status of enabled push notifications call `isOptIn()`, this will return true or false.\n\n```ts\nNsUrbanairship.getInstance().isOptIn();\n```\n\n#### Getting Channel ID\nTo get the channel ID call `getChannelID()`, this will return a string.\n\n```ts\nNsUrbanairship.getInstance().getChannelID();\n```\n\n#### Getting Registration Token\nTo get the registration token (APNS token for iOS and FCM token for Android) call `getRegistrationToken()`, this will return a string.\n\n```ts\nNsUrbanairship.getInstance().getRegistrationToken();\n```\n\n#### Resetting Badge Count (iOS only)\nTo reset the badge count call `resetBadgeCount()`.\n\n```ts\nNsUrbanairship.getInstance().resetBadgeCount();\n```\n\n#### Opening Preference Center\nTo open the preference center call `openPreferenceCenter()`.\n\n```ts\nNsUrbanairship.getInstance().openPreferenceCenter('PREFERENCE_CENTER_ID');\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fessent%2Fnativescript-urban-airship","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fessent%2Fnativescript-urban-airship","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fessent%2Fnativescript-urban-airship/lists"}