NativeScript / nativescript-facebook

NativeScript plugin, wrapper of native Facebook SDK for Android and iOS
Apache License 2.0
79 stars 50 forks source link

Android exception #121

Closed fhackenb closed 6 years ago

fhackenb commented 6 years ago

I have a fully working facebook integration on iOS but am consistently getting an error on android.

After adding the appropriate key hash to my facebook dashboard, I am getting this error:

System.err: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=64206, result=-1, data=Intent { (has extras) }} to activity {com.frontdor.app.android/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: System.err: Calling js method onActivityResult failed System.err: System.err: RangeError: Invalid time value System.err: File: "file:///data/data/com.frontdor.app.android/files/app/tns_modules/nativescript-facebook/login-manager.js, line: 65, column: 28 System.err: StackTrace: System.err: Frame: function:'convertToISOStringDate', file:'file:///data/data/com.frontdor.app.android/files/app/tns_modules/nativescript-facebook/login-manager.js', line: 116, column: 36 System.err: Frame: function:'getCurrentAccessToken', file:'file:///data/data/com.frontdor.app.android/files/app/tns_modules/nativescript-facebook/login-manager.js', line: 102, column: 38 System.err: Frame: function:'FacebookConnectComponent.getPages', file:'file:///data/data/com.frontdor.app.android/files/app/messenger/views/facebook-connect/facebook-connect.js', line: 46, column: 36 System.err: Frame: function:'', file:'file:///data/data/com.frontdor.app.android/files/app/messenger/views/facebook-connect/facebook-connect.js', line: 36, column: 27 System.err: Frame: function:'onSuccess', file:'file:///data/data/com.frontdor.app.android/files/app/tns_modules/nativescript-facebook/login-manager.js', line: 45, column: 13 System.err: Frame: function:'onActivityResult', file:'file:///data/data/com.frontdor.app.android/files/app/tns_modules/nativescript-facebook/login-manager.js', line: 65, column: 29 System.err: Frame: function:'Observable.notify', file:'file:///data/data/com.frontdor.app.android/files/app/tns_modules/tns-core-modules/data/observable/observable.js', line: 103, column: 23 System.err: Frame: function:'ActivityCallbacksImplementation.onActivityResult', file:'file:///data/data/com.frontdor.app.android/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 718, column: 29 System.err: Frame: function:'NativeScriptActivity.onActivityResult', file:'file:///data/data/com.frontdor.app.android/files/app/tns_modules/tns-core-modules/ui/frame/activity.js', line: 45, column: 25 System.err: System.err: at com.tns.Runtime.callJSMethodNative(Native Method) System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088) System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:970) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:957) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:941) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:933) System.err: at com.tns.NativeScriptActivity.onActivityResult(NativeScriptActivity.java:75) System.err: at android.app.Activity.dispatchActivityResult(Activity.java:7539) System.err: at android.app.ActivityThread.deliverResults(ActivityThread.java:4485)

I traced the error to login-manager.android.js:

accessToken.expirationDate = convertToISOStringDate(sdkAccessToken.getExpires().toGMTString()); accessToken.refreshDate = convertToISOStringDate(sdkAccessToken.getLastRefresh().toGMTString());

When I do a console log on the sdkAccessToken and sdkAccessToken.getExpires() I get this:

SDK ACCESS TOKEN : {AccessToken token:ACCESS_TOKEN_REMOVED permissions:[manage_pages, pages_messaging, public_profile, pages_show_list]} JS: Get expires: Sun Aug 17 02:12:55 EST 292278994

The time in the console log seems to look good, so not sure why it's getting convertToISOStringDate method is causing this error. The code immediately preceding this error is: Facebook.requestPublishPermissions(["manage_pages"], (error, fbData) => { ... })

lini commented 6 years ago

Hi, Although I was not able to reproduce this error, I have made some changes to the code you referenced so it handles unexpected input better. Here is the relevant PR: https://github.com/NativeScript/nativescript-facebook/pull/124

fhackenb commented 6 years ago

Awesome, I copied the code into my node_modules and it fixed my issue! When do you think you'll publish this version?

DimitarTodorov commented 6 years ago

nativescript-facebook@2.2.4 is now published in npm

fhackenb commented 6 years ago

Thanks!