Skip to content Skip to sidebar Skip to footer

Hooking Into Main Application's Oncreate Method From Adobe Air Extension

I am creating an ANE for Urban Airship, a service for sending push notifications (among other things). So far the integration has worked great but only when the app is open. When t

Solution 1:

Its common to see libs wanting to have the app initialize its module in the application's onCreate as its called before all services, receivers, or activities are created. Basically the only real entry point for all apps.

For frameworks like Adobe where its hard to call takeoff in the applicaiton file, we have added another way of calling takeoff using Autopilot.

Example:

publicclassAirAutopilotextendsAutopilot {
    @Overridepublic AirshipConfigOptions createAirshipConfigOptions(Context context) {
        AirshipConfigOptionsoptions=newAirshipConfigOptions();
        options.developmentAppKey = "xxx";
        options.developmentAppSecret = "xxx";
        options.inProduction = false;
        options.gcmSender = "000";

        return options;
    }

    @OverridepublicvoidonAirshipReady(UAirship airship) {
        Log.d("TakeoffFunction", "Urban Airship is ready after takeoff");
        airship.getPushManager().setUserNotificationsEnabled(true);
        Log.d("TakeoffFunction", "User notifications have been enabled");
    }
}

Then add the autopilot class to the manifest in the application block (not sure about the Adobe Air way of doing this):

<meta-data android:name="com.urbanairship.autopilot" android:value="com.example.AirAutopilot" />

Then in your plugin, make sure a call to autopilot is made before accessing the UAirship instance:

Autopilot.automaticTakeOff(context.getActivity().getApplication());

Post a Comment for "Hooking Into Main Application's Oncreate Method From Adobe Air Extension"