Skip to content

Commit

Permalink
Check GooglePlayServicesUtil and fixed gms prompt
Browse files Browse the repository at this point in the history
* Now prompts for Google Play services missing again.
* Added check for GooglePlayServicesUtil to better detect missing gms components.
  • Loading branch information
jkasten2 committed Jul 6, 2016
1 parent a11751e commit f8c19c9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Binary file modified OneSignalSDK.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public void init() {
private static TrackGooglePurchase trackGooglePurchase;
private static TrackAmazonPurchase trackAmazonPurchase;

public static final String VERSION = "020501";
public static final String VERSION = "020502";

private static AdvertisingIdentifierProvider mainAdIdProvider = new AdvertisingIdProviderGPS();

Expand Down Expand Up @@ -243,6 +243,13 @@ public static void init(Context context, String googleProjectNumber, String oneS
Log(LOG_LEVEL.FATAL, "The GCM Google Play services client library was not found. Please make sure to include it in your project.", e);
subscribableStatus = -4;
}

try {
Class.forName("com.google.android.gms.common.GooglePlayServicesUtil");
} catch (ClassNotFoundException e) {
Log(LOG_LEVEL.FATAL, "The GooglePlayServicesUtil class part of Google Play services client library was not found. Include this in your project.", e);
subscribableStatus = -4;
}
}

mGoogleProjectNumber = googleProjectNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ private boolean isGooglePlayStoreInstalled() {
}

private boolean checkPlayServices() {
// GoogleApiAvailability is the replacement for GooglePlayServicesUtil added in 7.3.

int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(appContext);
if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode) && isGooglePlayStoreInstalled()) {
Expand All @@ -103,15 +105,18 @@ private boolean checkPlayServices() {
}

private void ShowUpdateGPSDialog(final int resultCode) {
((Activity) appContext).runOnUiThread(new Runnable() {
OneSignal.runOnUiThread(new Runnable() {
@Override
public void run() {
AlertDialog.Builder builder = new AlertDialog.Builder(appContext);
final Activity activity = ActivityLifecycleHandler.curActivity;
if (activity == null)
return;
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setMessage("To receive push notifications please press 'Update' to enable 'Google Play services'.").setPositiveButton("Update", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
GooglePlayServicesUtil.getErrorPendingIntent(resultCode, appContext, 0).send();
GooglePlayServicesUtil.getErrorPendingIntent(resultCode, activity, 0).send();
} catch (CanceledException e) {
} catch (Throwable e) {
e.printStackTrace();
Expand All @@ -121,7 +126,7 @@ public void onClick(DialogInterface dialog, int which) {
}).setNegativeButton("Skip", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final SharedPreferences prefs = OneSignal.getGcmPreferences(appContext);
final SharedPreferences prefs = OneSignal.getGcmPreferences(activity);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("GT_DO_NOT_SHOW_MISSING_GPS", true);
editor.commit();
Expand Down

0 comments on commit f8c19c9

Please sign in to comment.