Skip to content
A Nativescript plugin that wraps the iOS and Android OneSignal Push Notifications SDK.
JavaScript TypeScript Ruby
Branch: master
Clone or download
Pull request Compare This branch is 1 commit ahead of roblav96:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
demo
lib
platforms
typings
.gitignore
.npmignore
LICENSE
README.md
index.d.ts
nativescript-onesignal.sublime-project
onesignal.android.d.ts
onesignal.android.ts
onesignal.ios.d.ts
onesignal.ios.ts
package.json
postinstall-hooks.js
preuninstall-hooks.js
tsconfig.json

README.md

NativeScript-OneSignal

A Nativescript plugin that wraps the iOS and Android OneSignal Push Notifications SDK.

Contributors

OneSignal-iOS-SDK

OneSignal-Android-SDK

Supported Platforms

  • iOS
  • Android

Installation

tns plugin add nativescript-onesignal

iOS

Does not need any configuration.

Android

Does not need any configuration.

Usage

Typescript

var TnsOneSignal = require('nativescript-onesignal').TnsOneSignal

iOS

TnsOneSignal is the native iOS OneSignal class.

In your main.ts:

import * as application from 'application';
var TnsOneSignal = require('nativescript-onesignal').TnsOneSignal

if (application.ios) {
	class MyDelegate extends UIResponder implements UIApplicationDelegate {

		public static ObjCProtocols = [UIApplicationDelegate]

		private applicationDidFinishLaunchingWithOptions(app: UIApplication, launchOptions: NSDictionary): boolean {

			try {

				console.dump('TnsOneSignal', TnsOneSignal)
				TnsOneSignal.initWithLaunchOptionsAppId(launchOptions, 'b2f7f966-d8cc-11e4-bed1-df8f05be55ba')

			} catch (error) {
				console.error('error', error)
			}

			return true
		}

	}
	application.ios.delegate = MyDelegate
}

Android

TnsOneSignal is the native Android com.onesignal.OneSignal class.

In your main.ts:

import * as application from 'application';
var TnsOneSignal = require('nativescript-onesignal').TnsOneSignal

if (application.android) {
	application.on(application.launchEvent, function(args: application.ApplicationEventData) {

		try {

			console.dump('TnsOneSignal', TnsOneSignal)
			TnsOneSignal.startInit(application.android.context).init()

		} catch (error) {
			console.error('error', error)
		}

	})
}

API Reference

iOS API Reference

Android API Reference

Typescript Typings

iOS

Android - In the works...

Demo

npm run setup
# iOS
npm run demo.ios
# Android
npm run demo.android
You can’t perform that action at this time.