Skip to content

Commit b028e35

Browse files
authored
Merge pull request #452 from Backendless/oleg.vyalyh/fixed_on_tap_action
BKNDLSS-20867 Fixed onTapAction.
2 parents 2d5708c + 52cd6be commit b028e35

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/com/backendless/push/PushTemplateHelper.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -252,17 +252,22 @@ else if( messageText.length() > 35 )
252252
.setContentTitle( contentTitle != null ? contentTitle : template.getContentTitle() )
253253
.setSubText( summarySubText != null ? summarySubText : template.getSummarySubText() )
254254
.setContentText( messageText );
255-
256-
String actionOnTap = (template.getActionOnTap() == null || template.getActionOnTap().isEmpty() )
257-
?appContext.getPackageName()
258-
:template.getActionOnTap();
259-
260-
Intent notificationIntent = appContext.getPackageManager().getLaunchIntentForPackage( actionOnTap );
261-
notificationIntent.putExtras( newBundle );
262-
notificationIntent.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
263-
264-
PendingIntent contentIntent = PendingIntent.getActivity( appContext, notificationId * 3, notificationIntent, 0 );
265-
notificationBuilder.setContentIntent( contentIntent );
255+
256+
Intent notificationIntent;
257+
if (template.getActionOnTap() == null || template.getActionOnTap().isEmpty())
258+
notificationIntent = appContext.getPackageManager().getLaunchIntentForPackage(appContext.getPackageName());
259+
else
260+
{
261+
notificationIntent = new Intent("ActionOnTap");
262+
notificationIntent.setClassName(appContext, template.getActionOnTap());
263+
}
264+
265+
notificationIntent.putExtras(newBundle);
266+
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
267+
PendingIntent contentIntent = PendingIntent.getActivity(appContext, notificationId * 3, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
268+
269+
// user should use messageId and tag(templateName) to cancel notification.
270+
notificationBuilder.setContentIntent(contentIntent);
266271

267272
if( template.getActions() != null )
268273
{

0 commit comments

Comments
 (0)