@rwigo/nativescript-onesignal
by rwigo | v1.0.2
Nativescript OneSignal SDK plugin
npm i --save @rwigo/nativescript-onesignal

@rwigo/nativescript-onesignal

This plugin used those SDK versions :

Installation

ns plugin add @rwigo/nativescript-onesignal

Usage

In the main.ts or app.ts file (depending on your configuration), add this initialization code :

import { Application, isAndroid, Utils } from '@nativescript/core';
import { NSOneSignal } from '@rwigo/nativescript-onesignal';

...

Application.on(Application.launchEvent, (args) => {
// Give context for Android and launchOptions for iOS when app is launching
NSOneSignal.getInstance().init('YOUR_APP_ID', isAndroid ? Utils.android.getApplicationContext() : args.ios);
NSOneSignal.getInstance().setNotificationHandlers(
(result) => {
console.log('notification opened');
},
(result) => {
console.log('notification will show in foreground');
}
);
});

Then you can import NativeOneSignal to use SDK API that hasn't been implemented in the NSOneSignal plugin class :

import { NativeOneSignal } from '@rwigo/nativescript-onesignal';

...

// Disabling push notification
NativeOneSignal.disablePush(true);

License

Apache License Version 2.0