4
4
import android .content .Context ;
5
5
import android .content .Intent ;
6
6
import android .content .SharedPreferences ;
7
+ import android .graphics .Rect ;
7
8
import android .os .Build ;
8
9
import android .os .Bundle ;
9
10
@@ -533,15 +534,22 @@ public void execute(String payload) {
533
534
JSONObject dialogOptions = IterableInAppManager .getNextMessageFromPayload (payload );
534
535
if (dialogOptions != null ) {
535
536
JSONObject message = dialogOptions .optJSONObject (IterableConstants .ITERABLE_IN_APP_CONTENT );
536
- int templateId = message .optInt (IterableConstants .KEY_TEMPLATE_ID );
537
-
538
- int campaignId = dialogOptions .optInt (IterableConstants .KEY_CAMPAIGN_ID );
539
- String messageId = dialogOptions .optString (IterableConstants .KEY_MESSAGE_ID );
540
-
541
- IterableApi .sharedInstance .trackInAppOpen (campaignId , templateId , messageId );
542
- IterableApi .sharedInstance .inAppConsume (messageId );
543
- IterableInAppManager .showNotification (context , message , messageId , clickCallback );
544
-
537
+ if (message != null ) {
538
+ String messageId = dialogOptions .optString (IterableConstants .KEY_MESSAGE_ID );
539
+ String html = message .optString ("html" );
540
+ if (html .toLowerCase ().contains ("href" )) {
541
+ JSONObject paddingOptions = message .optJSONObject ("inAppDisplaySettings" );
542
+ Rect padding = IterableInAppManager .getPaddingFromPayload (paddingOptions );
543
+
544
+ double backgroundAlpha = message .optDouble ("backgroundAlpha" , 0 );
545
+ IterableInAppManager .showIterableNotificationHTML (context , html , messageId , clickCallback , backgroundAlpha , padding );
546
+ } else {
547
+ IterableLogger .w (TAG , "No href tag in found in the in-app html payload: " + html );
548
+ }
549
+
550
+ IterableApi .sharedInstance .inAppConsume (messageId );
551
+
552
+ }
545
553
}
546
554
}
547
555
});
@@ -558,6 +566,8 @@ public void getInAppMessages(int count, IterableHelper.IterableActionHandler onC
558
566
try {
559
567
addEmailOrUserIdToJson (requestJSON );
560
568
requestJSON .put (IterableConstants .ITERABLE_IN_APP_COUNT , count );
569
+ requestJSON .put (IterableConstants .KEY_PLATFORM , IterableConstants .ITBL_PLATFORM_ANDROID );
570
+ requestJSON .put (IterableConstants .ITBL_KEY_SDK_VERSION , IterableConstants .ITBL_KEY_SDK_VERSION_NUMBER );
561
571
}
562
572
catch (JSONException e ) {
563
573
e .printStackTrace ();
@@ -567,17 +577,13 @@ public void getInAppMessages(int count, IterableHelper.IterableActionHandler onC
567
577
568
578
/**
569
579
* Tracks an InApp open.
570
- * @param campaignId
571
- * @param templateId
572
580
* @param messageId
573
581
*/
574
- public void trackInAppOpen (int campaignId , int templateId , String messageId ) {
582
+ public void trackInAppOpen (String messageId ) {
575
583
JSONObject requestJSON = new JSONObject ();
576
584
577
585
try {
578
586
addEmailOrUserIdToJson (requestJSON );
579
- requestJSON .put (IterableConstants .KEY_CAMPAIGN_ID , campaignId );
580
- requestJSON .put (IterableConstants .KEY_TEMPLATE_ID , templateId );
581
587
requestJSON .put (IterableConstants .KEY_MESSAGE_ID , messageId );
582
588
}
583
589
catch (JSONException e ) {
@@ -590,15 +596,15 @@ public void trackInAppOpen(int campaignId, int templateId, String messageId) {
590
596
/**
591
597
* Tracks an InApp click.
592
598
* @param messageId
593
- * @param buttonIndex
599
+ * @param urlClick
594
600
*/
595
- public void trackInAppClick (String messageId , int buttonIndex ) {
601
+ public void trackInAppClick (String messageId , String urlClick ) {
596
602
JSONObject requestJSON = new JSONObject ();
597
603
598
604
try {
599
605
addEmailOrUserIdToJson (requestJSON );
600
606
requestJSON .put (IterableConstants .KEY_MESSAGE_ID , messageId );
601
- requestJSON .put (IterableConstants .ITERABLE_IN_APP_BUTTON_INDEX , buttonIndex );
607
+ requestJSON .put (IterableConstants .ITERABLE_IN_APP_URL_CLICK , urlClick );
602
608
}
603
609
catch (JSONException e ) {
604
610
e .printStackTrace ();
0 commit comments