[MOD-2397] Ti.Facebook: Uncaught exception when accessing "getExpirationDate()" on invalid access-token

GitHub Issuen/a
Resolution Date2018-02-10T18:04:05.000+0000
Affected Version/sn/a
Fix Version/s Ti.Facebook iOS 4.7.1, Ti.Facebook Android 7.1.1
ReporterDavid Benko
AssigneeHans Knöchel


In my app I log uncaught exceptions that happens, and frequently I get the following error: Uncaught Attempt to invoke virtual method 'java.util.Date com.facebook.AccessToken.getExpires()' on a null object reference I suppose is some error in the internal java code on the Facebook module that happens when the user logs in. Unfortunatelly I dont have more info on the error because I can't reproduce, but from the error description itself it seems like some null verifications are missing in the module


  1. Sharif AbuDarda 2018-02-08 Hello, Can you provide a trace log of your issue? Without the trace log or a sample reproducible code, we are unable to help you. Thanks.
  2. David Benko 2018-02-08 Check this line: https://github.com/appcelerator-modules/ti.facebook/blob/master/android/src/facebook/TiFacebookModule.java#L342 The problem is the call
    Beucase AccessToken.getCurrentAccessToken() returns null then .getExpires() is called on null reference. You can see that other methods have a null check before:
       if (AccessToken.getCurrentAccessToken() != null) {
       	return AccessToken.getCurrentAccessToken().getToken();
    Just need to add a null check to getExpirationDate method too
  3. Hans Knöchel 2018-02-10 Thanks for the details! We can fix that. But I am still wondering if you couldn't just check for the accessToken or loggedIn property before and only call getExpirationDate() if it's valid.
  4. Hans Knöchel 2018-02-10 New release: https://github.com/appcelerator-modules/ti.facebook/releases/tag/android-7.1.1
  5. Eric Merriman 2018-08-06 Cleaning up older fixed issues. If this issue should not have been closed as fixed, please reopen.

JSON Source