Rob Laverty Rob Laverty - 1 year ago 158
TypeScript Question

How to Extend Application Class on Android with Angular nativeScriptBootstrap

I'm trying to implement OneSignal's Push Notification SDK on android and in order to do so, I need to Extend Application Class and call
in the

I've been following the guides posted in the documentation and the
Android Extend Sample App
. Neither of these are working at all.

Trying to build the
Android Extend Sample App
results in
Java ID 0 not found

I'm also exploring the possibility of
export class AppComponent extends
which I'm having no luck with so far.

Any tips would greatly be appreciated!

Answer Source

There are two ways to achieve this the later being the complicated one

Place the following in your main.ts

var application = require("application");
application.on(application.launchEvent, function (args) {
    if ( {
        // For Android applications
    } else if (args.ios !== undefined) {
        // For iOS applications, args.ios

Create a new JavaScript file in your app folder - name it

var application = require("application");
var superProto =;
var Application ="org.myApp.Application", {
    onCreate: function () {;;

Modify the application entry within the AndroidManifest.xml file found in the <application-name>app/App_Resources/Android/ folder

        android:theme="@style/AppTheme" >
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download