npm i --save @rwigo/nativescript-onesignal
- Version: 1.0.3
- GitHub: https://github.com/NativeScript/plugins
- NPM: https://www.npmjs.com/package/%40rwigo%2Fnativescript-onesignal
- Downloads:
- Last Day: 0
- Last Week: 0
- Last Month: 0
@rwigo/nativescript-onesignal
This plugin used those SDK versions :
- Android OneSignal SDK - 5.0.5
- iOS OneSignal SDK - ^3.11.2
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