Ron Harlev
Ron Harlev

Reputation: 16713

Phonegap Android with TestFlight SDK, sessions are not tracked

I have a Phonegap 3.0 Android app, with the TestFlight SDK integrated.

The TestFlight website recognized my app has the SDK embedded (green check mark shows in the SDK column, on the build version line).
Yet, the TestFlight website doesn't show the user sessions when the app is in use.

Here is how I implemented it:

The documentation specified I should use this code

public class MyApplication extends Application {
  @Override
  public void onCreate() {
    super.onCreate();
    //Initialize TestFlight with your app token.
    TestFlight.takeOff(this, YOUR_APP_TOKEN);
    ...
  }
}

In Phonegap the class actually extends DroidGap (which is not an application). So I had to do instead

TestFlight.takeOff(this.getApplication(), TEST_FLIGHT_APP_TOKEN);

Also, it says AndroidManifest.xml should have

<application ... android:name="MyApplication">  

When I add that (pointing to my main class (the one which extends DroidGap) I get an exception when the app loads java.lang.ClassCastException casting from my main class to android.app.Application

It looks like there should be a main class that extends Application, but I can't seem to find it.

Upvotes: 0

Views: 948

Answers (1)

swerv1
swerv1

Reputation: 41

You should setup a separate java class in your project that extends Application, and call takeOff in onCreate

     public class MyApplication extends Application { 

              @Override 
                 public void onCreate() { 
                     TestFlight.takeOff(this, YOUR_APP_TOKEN);
                     super.onCreate(); 
                 } 

     } 

You should not put the name of your Activity (which extends DroidGap) in the Application tag of the manifest, as this will cause a ClassCastException. Instead, use the name of the class extending Application, in this example "MyApplication".

Upvotes: 4

Related Questions