PushTemplates icon indicating copy to clipboard operation
PushTemplates copied to clipboard

PushTemplateMessagingService is not getting push notification

Open jagdish-dhani opened this issue 5 years ago • 3 comments

Hello, How template notificatin will come inside PushTemplateMessagingService ?? means, inside : onMessageReceived

if (Utils.isForPushTemplates(extras)) {
                        TemplateRenderer.createNotification(context, extras);
                        //TemplateRenderer.createNotification(context, extras, config);
                    }

Right now it is not coming at all. I've tried combination of these manifest. If i write all previous-current receiver and service then also not coming in my PushTemplateMessagingService If i write only default service then also not coming in the PushTemplateMessagingService If i write my custom service then also not coming in the PushTemplateMessagingService Not coming any logs.

We have also tried Test.zip Given by you guys but in that also not having any other extra code then this for Clevertap template.

Sample Code which we are using

My previous receiver and service

`        <receiver
            android:name="com.clevertap.android.sdk.pushnotification.CTPushNotificationReceiver"
            android:enabled="true"
            android:exported="false" />

        <service
            android:name="com.clevertap.android.sdk.pushnotification.CTNotificationIntentService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.clevertap.PUSH_EVENT" />
            </intent-filter>
        </service>`

default template manifest setting

        <service
            android:name="com.clevertap.pushtemplates.PTNotificationIntentService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.clevertap.PT_PUSH_EVENT"/>
            </intent-filter>
        </service>

        <service
           android:name="com.clevertap.pushtemplates.PTNotificationIntentService"
           android:exported="false">
            <intent-filter>
              <action android:name="com.clevertap.PT_PUSH_EVENT"/>
            </intent-filter>
        </service>

        <receiver
            android:name="com.clevertap.pushtemplates.PTPushNotificationReceiver"
            android:exported="false"
            android:enabled="true">
        </receiver>

        <receiver
            android:name="com.clevertap.pushtemplates.PushTemplateReceiver"
            android:exported="false"
            android:enabled="true">
        </receiver>

Custom Template setting

<service
            android:name="**mypackage**.PushTemplateMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>

Not coming in the PushTemplateMessagingService in any case

this class is under our package
public class PushTemplateMessagingService extends FirebaseMessagingService {

    Context context;

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        try {
            PTLog.debug("Inside Push Templates");
            context = getApplicationContext();
            if (remoteMessage.getData().size() > 0) {
                Bundle extras = new Bundle();

                for (Map.Entry<String, String> entry : remoteMessage.getData().entrySet()) {
                    extras.putString(entry.getKey(), entry.getValue());
                }
                
                NotificationInfo info = CleverTapAPI.getNotificationInfo(extras);
                //If you are using CleverTapInstanceConfig to create the CleverTap instance use the commented code
                //CleverTapInstanceConfig config = CleverTapInstanceConfig.createInstance(getApplicationContext(),
                //        "YOUR_ACCOUNT_ID","YOUR_ACCOUNT_TOKEN","YOUR_ACCOUNT_REGION");
                if (info.fromCleverTap) {
                    if (Utils.isForPushTemplates(extras)) {
                        TemplateRenderer.createNotification(context, extras);
                        //TemplateRenderer.createNotification(context, extras, config);
                    } else {
                        CleverTapAPI.createNotification(context, extras);
                    }
                }
            }
        } catch (Throwable throwable) {
            PTLog.verbose("Error parsing FCM payload", throwable);
        }
    }
    @Override
    public void onNewToken(@NonNull final String s) {
        //no-op
    }
}

jagdish-dhani avatar Aug 13 '21 09:08 jagdish-dhani

I am also getting the same. Any updates regarding this?

sangupandi avatar Sep 08 '21 15:09 sangupandi

@sangupandi @jagdish-dhani We will need your APK to get more info. I would suggest raising a support issue via the dashboard mentioning this Github issue and we'll try and expedite it.

darshanclevertap avatar Sep 09 '21 06:09 darshanclevertap

Closing this as it has been suggested to reach out to CleverTap Support Team

darshanclevertap avatar Oct 04 '21 07:10 darshanclevertap