Skip to content

Commit

Permalink
Ensure that Facebook SDK is initialized. Also fixed up FacebookDatum …
Browse files Browse the repository at this point in the history
…nullable property type checking.
  • Loading branch information
MatthewGerber committed Sep 7, 2015
1 parent 4c7c099 commit 80255cb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions Sensus.Android/AndroidMainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,15 @@ protected override void OnActivityResult(int requestCode, Result resultCode, Int
_activityResultWait.Set();
}

// looks like the facebook SDK can become uninitialized during the process of interacting with the Facebook login manager. this
// might happen when Sensus is stopped/destroyed while the user is logging into facebook. check here to ensure that the facebook
// SDK is initialized.
//
// see: https://insights.xamarin.com/app/Sensus-Production/issues/66
//
if (!FacebookSdk.IsInitialized)
FacebookSdk.SdkInitialize(this);

_facebookCallbackManager.OnActivityResult(requestCode, (int)resultCode, data);
}

Expand Down
4 changes: 2 additions & 2 deletions Sensus.Android/Probes/Apps/AndroidFacebookProbe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ protected override IEnumerable<Datum> Poll(CancellationToken cancellationToken)

if (property.PropertyType == typeof(string))
value = responseJSON.GetString(jsonField);
else if (property.PropertyType == typeof(bool))
else if (property.PropertyType == typeof(bool?))
value = responseJSON.GetBoolean(jsonField);
else if (property.PropertyType == typeof(DateTimeOffset))
else if (property.PropertyType == typeof(DateTimeOffset?))
value = DateTimeOffset.Parse(responseJSON.GetString(jsonField));
else if (property.PropertyType == typeof(List<string>))
{
Expand Down
4 changes: 2 additions & 2 deletions Sensus.iOS/Probes/Apps/iOSFacebookProbe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ protected override IEnumerable<Datum> Poll(CancellationToken cancellationToken)

if (property.PropertyType == typeof(string))
value = resultDictionary[resultKey].ToString();
else if (property.PropertyType == typeof(bool))
else if (property.PropertyType == typeof(bool?))
{
int parsedBool;
if (int.TryParse(resultDictionary[resultKey].ToString(), out parsedBool))
value = parsedBool == 1 ? true : false;
}
else if (property.PropertyType == typeof(DateTimeOffset))
else if (property.PropertyType == typeof(DateTimeOffset?))
{
DateTimeOffset parsedDateTimeOffset;
if (DateTimeOffset.TryParse(resultDictionary[resultKey].ToString(), out parsedDateTimeOffset))
Expand Down

0 comments on commit 80255cb

Please sign in to comment.