GithubHelp home page GithubHelp logo

jalberto-ghub / nativescript-onesignal Goto Github PK

View Code? Open in Web Editor NEW

This project forked from roblav96/nativescript-onesignal

0.0 0.0 0.0 8.32 MB

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

Home Page: https://documentation.onesignal.com/docs/getting-started

License: Other

TypeScript 9.67% Ruby 0.72% JavaScript 89.61%

nativescript-onesignal's Introduction

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

nativescript-onesignal's People

Contributors

roblav96 avatar jkasten2 avatar robophil avatar ericky14 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.