我收到来自信号的通知,其中包含从服务发送的actionButtons。我该如何处理这些按钮并处理他们的事件?
protected boolean onNotificationProcessing(final OSNotificationReceivedResult receivedResult) {
OverrideSettings overrideSettings = new OverrideSettings();
// here I am getting the data sent thtough oneSignal
final JSONObject additionalData = receivedResult.payload.additionalData;
// here I am getting my buttons
final List<OSNotificationPayload.ActionButton> actionButtons = receivedResult.payload.actionButtons;
overrideSettings.extender = new NotificationCompat.Extender() {
@Override
public NotificationCompat.Builder extend(NotificationCompat.Builder builder) {
try {
// Here I am creating my own button and adding it to the notification
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" + phoneNumber));
PendingIntent pendingIntentCall = PendingIntent.getActivity(MyService.this, 12345, intent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.addAction(R.drawable.phone_notif,getString(R.string.call),pendingIntentCall);
} catch (Exception e) {
}
return builder;
}
};
return true
}
如何处理从一个信号接收的actionButtons的事件?它们出现了但是当我点击它们时,它们就像我点击通知一样......
答案 0 :(得分:0)
OneSignal的Android SDK为收到的通知提供处理程序。您应该为按钮设置ID以区分彼此。您还可以将其他数据(例如,要访问的网址或其他元数据)作为re.findall(r'\w{{{}}}'.format(order), text)
密钥下的哈希发送。来自documentation:
data