open-index/open-npm huggingface dataset:
npm package: @rwigo/nativescript-onesignal
Description: Nativescript OneSignal SDK plugin
Author: Killian DROULEZ
Latest version: 1.0.3

# @rwigo/nativescript-onesignal

This plugin used those SDK versions :

- [Android OneSignal SDK](https://github.com/OneSignal/OneSignal-Android-SDK) - 5.0.5
- [iOS OneSignal SDK](https://github.com/OneSignal/OneSignal-iOS-SDK) - ^3.11.2

## Installation

```javascript
ns plugin add @rwigo/nativescript-onesignal
```

## Usage

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

```ts
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 :

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

...

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

## License

Apache License Version 2.0