@@ -154,7 +154,6 @@ public static void setGcmSenderIds(String... senderIds) {
154154 * with each module separately.
155155 *
156156 * For example:
157- * implementation 'com.leanplum:leanplum-core:+'
158157 * implementation 'com.leanplum:leanplum-fcm:+'
159158 * implementation 'com.leanplum:leanplum-location:+'
160159 */
@@ -733,21 +732,36 @@ public static void setGcmRegistrationId(String token) {
733732 * Call this when Leanplum starts. This method will call by reflection from AndroidSDKCore.
734733 */
735734 static void onStart () {
736- boolean callFcmOnStart = isFirebaseEnabled ();
737- if (!callFcmOnStart ) {
735+ Class leanplumGcmPushServiceClass = null ;
736+ Class leanplumFcmPushServiceClass = null ;
737+
738+ try {
739+ leanplumGcmPushServiceClass = Class .forName (LEANPLUM_PUSH_SERVICE_GCM );
740+ } catch (Throwable ignored ) {
741+ }
742+
743+ try {
744+ leanplumFcmPushServiceClass = Class .forName (LEANPLUM_PUSH_SERVICE_FCM );
745+ } catch (Throwable ignored ) {
746+ }
747+
748+ if (leanplumGcmPushServiceClass != null && leanplumFcmPushServiceClass != null ) {
749+ Log .e ("Leanplum does not support leanplum-gcm and leanplum-fcm library at the " +
750+ "same time. To support Leanplum GCM and Location services modify your build.gradle by " +
751+ "including only implementation 'com.leanplum:leanplum:+' " +
752+ "To support only GCM services, use implementation 'com.leanplum:leanplum-gcm:+' " +
753+ "For FCM services include implementation 'com.leanplum:leanplum-fcm:+'" +
754+ " If you wish to use Leanplum FCM and Location services you also need to include " +
755+ "implementation 'com.leanplum:leanplum-location:+'." );
756+
757+ } else if (leanplumGcmPushServiceClass != null ) {
738758 try {
739- Class .forName (LEANPLUM_PUSH_SERVICE_GCM ).getDeclaredMethod ("onStart" )
740- .invoke (null );
759+ leanplumGcmPushServiceClass .getDeclaredMethod ("onStart" ).invoke (null );
741760 } catch (Throwable ignored ) {
742- callFcmOnStart = true ;
743761 }
744- }
745-
746- // Try starting FCM if GCM module is not included.
747- if (callFcmOnStart ) {
762+ } else if (leanplumFcmPushServiceClass != null ) {
748763 try {
749- Class .forName (LEANPLUM_PUSH_SERVICE_FCM ).getDeclaredMethod ("onStart" )
750- .invoke (null );
764+ leanplumFcmPushServiceClass .getDeclaredMethod ("onStart" ).invoke (null );
751765 } catch (Throwable ignored ) {
752766 }
753767 }
0 commit comments