roblav96 / nativescript-onesignal

A Nativescript plugin that wraps the iOS and Android OneSignal Push Notifications SDK.
https://documentation.onesignal.com/docs/getting-started
Other
24 stars 42 forks source link

TnsOneSignal undefined in Android #31

Closed dariopellegrini closed 6 years ago

dariopellegrini commented 6 years ago

TnsOneSignal is undefined in Android with latest version installed with tns.

Any solution? com.onesignal.OneSignal is undefined as well.

dariopellegrini commented 6 years ago

Error fixed making tns platform remove android and tns platform add android. Here's the code for a NativeScript Angular app.

import { Component } from "@angular/core";
import { on as applicationOn, launchEvent, suspendEvent, resumeEvent, exitEvent, lowMemoryEvent, uncaughtErrorEvent, ApplicationEventData, start as applicationStart } from "application";

@Component({
    selector: "ns-app",
    templateUrl: "app.component.html",
})

export class AppComponent { 

}
import * as application from 'application';
var TnsOneSignal = require('nativescript-onesignal').TnsOneSignal
applicationOn(launchEvent, function (args: ApplicationEventData) {
    if (args.android) {
        // For Android applications, args.android is an android.content.Intent class.
        console.log("Launched Android application with the following context: " + application.android.context + ".")
        TnsOneSignal.startInit(application.android.context)
                .init()
    }
});