我尝试使用 Pinpoint 向我的应用程序添加推送通知功能,但我有一个问题:推送通知显示,但当我单击它时没有任何操作。 我收到有关服务的通知。我像这样构建我的通知:
val notifDetail = NotificationDetails.builder()
.from(message.from)
.mapData(data)
.intentAction(NotificationClient.FCM_INTENT_ACTION)
.build()
然后我使用 handleCampaignPush 来显示推送:
notifClient.handleCampaignPush(notifDetail)
我尝试在通知详细信息生成器上使用参数 .intent :(但没有结果
有人有想法吗?
谢谢!
尝试将其添加到清单文件中:
<receiver
android:name="com.amazonaws.mobileconnectors.pinpoint.targeting.notification.PinpointNotificationReceiver">
<intent-filter>
<action android:name="com.amazonaws.intent.baidu.NOTIFICATION_OPEN" />
</intent-filter>
</receiver>
这应该有效。
您可能需要添加代码以处理传入的推送通知。
private final BroadcastReceiver notificationReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(LOG_TAG, "Received notification from local broadcast. Display it in a dialog.");
Bundle data = intent.getBundleExtra(PushListenerService.INTENT_SNS_NOTIFICATION_DATA);
String message = PushListenerService.getMessage(data);
new AlertDialog.Builder(MainActivity.this)
.setTitle("Push notification")
.setMessage(message)
.setPositiveButton(android.R.string.ok, null)
.show();
}
};
https://docs.aws.amazon.com/aws-mobile/latest/developerguide/add-aws-mobile-push-notifications.html