@@ -108,10 +108,10 @@ internal class CTWrapper(
108108 setDevicesProperty()
109109 }
110110 Log .d(" Wrapper: CleverTap instance created by Leanplum" )
111- }
112- if (firstTimeStart) {
113- // Send tokens in same session, because often a restart is needed for CT SDK to get them
114- sendPushTokens(context)
111+ if (firstTimeStart) {
112+ // Send tokens in the first session, because a restart is needed for CT SDK to get them
113+ sendPushTokens(context, this )
114+ }
115115 }
116116 triggerInstanceCallbacks()
117117 }
@@ -137,29 +137,20 @@ internal class CTWrapper(
137137 instanceCallbackList.remove(callback)
138138 }
139139
140- @SuppressLint(" RestrictedApi" )
141- private fun sendAppLaunchedEvent () {
142- cleverTapInstance?.coreState?.analyticsManager?.pushAppLaunchedEvent()?.also {
143- Log .d(" Wrapper: app launched event sent" )
144- }
145- }
146-
147- private fun sendPushTokens (context : Context ) {
140+ private fun sendPushTokens (context : Context , cleverTap : CleverTapAPI ) {
148141 // FCM
149142 val fcmToken = SharedPreferencesUtil .getString(context,
150143 Constants .Defaults .LEANPLUM_PUSH , Constants .Defaults .PROPERTY_FCM_TOKEN_ID )
151144 if (! TextUtils .isEmpty(fcmToken)) {
152- val type = PushConstants .PushType .FCM .type
153- PushNotificationHandler .getPushNotificationHandler().onNewToken(context, fcmToken, type)
145+ cleverTap.pushFcmRegistrationId(fcmToken, true )
154146 Log .d(" Wrapper: fcm token sent" )
155147 }
156148
157149 // HMS
158150 val hmsToken = SharedPreferencesUtil .getString(context,
159151 Constants .Defaults .LEANPLUM_PUSH , Constants .Defaults .PROPERTY_HMS_TOKEN_ID )
160152 if (! TextUtils .isEmpty(hmsToken)) {
161- val type = PushConstants .PushType .HPS .type
162- PushNotificationHandler .getPushNotificationHandler().onNewToken(context, hmsToken, type)
153+ cleverTap.pushHuaweiRegistrationId(hmsToken, true )
163154 Log .d(" Wrapper: hms token sent" )
164155 }
165156 }
0 commit comments