AppsFlyer Xamarin iOS binding, null reference exception

290 views Asked by At

https://github.com/AppsFlyerSDK/XamariniOSBinding

Is anyone able to get this repo running?

I am hitting an null reference exception on startup because the tracker object is null - although this is bound as a static in the API Definition

// +(AppsFlyerTracker *)sharedTracker;
        [Static, Export ("sharedTracker")]
        AppsFlyerTracker SharedTracker ();
2

There are 2 answers

0
Jader Feijo On BEST ANSWER

I was having the exact same issue and I found out what the problem is. I was testing this using the simulator.

The AppsFlyer SDK returns null for the AppsFlyerTracker.SharedTracker() method if the app is running on the simulator. Make sure that you run the app on a real device, and that you check for a null before calling methods on SharedTracker() otherwise you'll get a NullPointerException from Xamarin.

1
Dan Linenberg On

Make sure you've added a reference to AppsFlyerXamarinBinding.dll in your project's references, under .Net Assembly. The dll file can be found in the project's Bin/Debug folder (you'll have to build the binding project first in order to generate an updated dll file).

Also, add "using AppsFlyerXamarinBinding" in your delegate.