File tree Expand file tree Collapse file tree 3 files changed +15
-13
lines changed
AndroidSDKCore/src/main/java/com/leanplum
AndroidSDKPush/src/main/java/com/leanplum
AndroidSDKTests/src/test/java/com/leanplum Expand file tree Collapse file tree 3 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -630,18 +630,14 @@ public void run() {
630630 * Checks for leanplum notifications modules and if someone present - invoke onStart method.
631631 */
632632 private static void checkAndStartNotificationsModules () {
633- if (Util .hasPlayServices ()) {
634- try {
635- Log .d ("Trying to starting LeanplumPushService" );
633+ try {
634+ Log .d ("Trying to start LeanplumPushService" );
636635
637- Class .forName (LEANPLUM_PUSH_SERVICE )
638- .getDeclaredMethod ("onStart" )
639- .invoke (null );
640- } catch (Throwable ignored ) {
641- // ignored
642- }
643- } else {
644- Log .d ("No valid Google Play Services APK found." );
636+ Class .forName (LEANPLUM_PUSH_SERVICE )
637+ .getDeclaredMethod ("onStart" )
638+ .invoke (null );
639+ } catch (Throwable ignored ) {
640+ // ignored
645641 }
646642 }
647643
Original file line number Diff line number Diff line change @@ -71,6 +71,11 @@ public void run() {
7171 }
7272
7373 private static IPushProvider createFcm () {
74+ if (!Util .hasPlayServices ()) {
75+ Log .i ("No valid Google Play Services APK found. FCM will not initialize." );
76+ return null ;
77+ }
78+
7479 try {
7580 IPushProvider fcmProvider =
7681 (IPushProvider ) Class .forName (FCM_PROVIDER_CLASS ).getConstructor ().newInstance ();
Original file line number Diff line number Diff line change @@ -117,11 +117,12 @@ public class LeanplumPushServiceTest {
117117 */
118118 @ Before
119119 public void setUp () {
120- mockStatic (LeanplumPushService .class );
120+ mockStatic (Util .class );
121121 spy (LeanplumPushService .class );
122- spy (Util .class );
123122 spy (PushProviders .class );
124123
124+ when (Util .hasPlayServices ()).thenReturn (true );
125+
125126 this .context = RuntimeEnvironment .application ;
126127 assertNotNull (this .context );
127128 Leanplum .setApplicationContext (this .context );
You can’t perform that action at this time.
0 commit comments