44import android .content .Context ;
55import android .content .Intent ;
66import android .content .SharedPreferences ;
7+ import android .graphics .Rect ;
78import android .os .Build ;
89import android .os .Bundle ;
910
@@ -533,15 +534,22 @@ public void execute(String payload) {
533534 JSONObject dialogOptions = IterableInAppManager .getNextMessageFromPayload (payload );
534535 if (dialogOptions != null ) {
535536 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+ }
545553 }
546554 }
547555 });
@@ -558,6 +566,8 @@ public void getInAppMessages(int count, IterableHelper.IterableActionHandler onC
558566 try {
559567 addEmailOrUserIdToJson (requestJSON );
560568 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 );
561571 }
562572 catch (JSONException e ) {
563573 e .printStackTrace ();
@@ -567,17 +577,13 @@ public void getInAppMessages(int count, IterableHelper.IterableActionHandler onC
567577
568578 /**
569579 * Tracks an InApp open.
570- * @param campaignId
571- * @param templateId
572580 * @param messageId
573581 */
574- public void trackInAppOpen (int campaignId , int templateId , String messageId ) {
582+ public void trackInAppOpen (String messageId ) {
575583 JSONObject requestJSON = new JSONObject ();
576584
577585 try {
578586 addEmailOrUserIdToJson (requestJSON );
579- requestJSON .put (IterableConstants .KEY_CAMPAIGN_ID , campaignId );
580- requestJSON .put (IterableConstants .KEY_TEMPLATE_ID , templateId );
581587 requestJSON .put (IterableConstants .KEY_MESSAGE_ID , messageId );
582588 }
583589 catch (JSONException e ) {
@@ -590,15 +596,15 @@ public void trackInAppOpen(int campaignId, int templateId, String messageId) {
590596 /**
591597 * Tracks an InApp click.
592598 * @param messageId
593- * @param buttonIndex
599+ * @param urlClick
594600 */
595- public void trackInAppClick (String messageId , int buttonIndex ) {
601+ public void trackInAppClick (String messageId , String urlClick ) {
596602 JSONObject requestJSON = new JSONObject ();
597603
598604 try {
599605 addEmailOrUserIdToJson (requestJSON );
600606 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 );
602608 }
603609 catch (JSONException e ) {
604610 e .printStackTrace ();
0 commit comments