By integrating with this function, developers can dilivery message to their application at a specail target device or all devices that installed their application.
Refer to the SetUp
<!-- Add below meta-data to support Cloud Message -->
<meta-data android:name="PAXVAS_CloudMessage"
android:value="true"/>
See the sample PushMessageReceiver
<receiver android:name=".PushMessageReceiver"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="com.paxstore.mpush.NOTIFY_DATA_MESSAGE_RECEIVED" />
<action android:name="com.paxstore.mpush.DATA_MESSAGE_RECEIVED" />
<action android:name="com.paxstore.mpush.NOTIFICATION_MESSAGE_RECEIVED" />
<action android:name="com.paxstore.mpush.NOTIFY_MEDIA_MESSAGE_RECEIVED" />
<action android:name="com.paxstore.mpush.NOTIFICATION_CLICK" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
For this action you can get three types of data, title of the notification, content of the notification, jsonString sent to terminal that you can do logic with.
Only content jsonString you will receive.
Only title of the notification, content of the notification you will receive.
You will also get notified while the notification clicked by user, and you can retreive data that you have sent to your application.
Only media jsonString you will receive. You can choose when to show the media message.
For media message, we only store the last one pushed from server. Your application will immediately notice the message if your receiver registered ACTION_NOTIFY_MEDIA_MESSAGE_RECEIVED. You can choose to show the media message immediately or later. Media Message can be shown as you previewed in the web through below api. Or you can get media message details to show your own customized dialog.
int showResult = AdvertisementDialog.show(context, false, new AdvertisementDialog.OnLinkClick() {
@Override
public void onLinkClick(String linkUrl) {
clickedLink = true;
Toast.makeText(MainActivity.this, linkUrl, Toast.LENGTH_SHORT).show();
}
});
StoreSdk.getInstance().getMediaMesage(context);
//The sdk will show notification for Cloud Messag, you can customized it.
Notifications.I.init(getApplicationContext())
.setSmallIcon(R.drawable.logo_demo_white)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.logo_demo)) // If it is Android 12 or above, this will not take effect
.setOnlyAlertOnce(false) // Set this flag if you would only like the sound, vibrate and ticker to be played if the notification is not already showing.
.setAutoCancel(true) // Setting this flag will make it so the notification is automatically canceled when the user clicks it in the panel. The PendingIntent set with setDeleteIntent will be broadcast when the notification is canceled
.setCustomContentView(yourCustomContentView) // Supply a custom RemoteViews to use instead of the standard one.If it's Android 12 or above, this is the folded notification view
.setCustomBigContentView(yourCustomBigContentView); // Supply a custom RemoteViews to use instead of the expanded view(This is the expansion notification view for Android 12 and above)
//Or you can disable it.
Notifications.I.setEnabled(false);
- PAXSTORE client version 7.0+
- Market subscribes the Cloud Message service.