public void Setup(SwrveBaseCampaign campaign)
 {
     this.campaign = campaign;
     this.GetComponentInChildren <Text>().text = campaign.Subject;
     buttonComponent = this.GetComponent <Button>();
     updateButtonLayout();
 }
        protected virtual void ProcessCampaignJSON(Dictionary <string, object> campaignData)
        {
            HashSet <SwrveAssetsQueueItem> assetsQueue   = new HashSet <SwrveAssetsQueueItem>();
            ISwrveAssetsManager            assetsManager = this.sdk.GetSwrveAssetsManager();

            try {
                // Stop if we got an empty json
                if (campaignData != null)
                {
                    SwrveBaseCampaign campaign = SwrveBaseCampaign.LoadFromJSONWithNoValidation(assetsManager,
                                                                                                campaignData,
                                                                                                this.sdk.GetInitialisedTime(),
                                                                                                this.sdk.config.DefaultBackgroundColor);
                    if (campaign == null)
                    {
                        throw new Exception("Campaign was not in a format that could be parsed");
                    }
                    // For embedded Camapign we just trigger the callback, there is not assets do download.
                    if (campaign is SwrveEmbeddedCampaign)
                    {
                        if (sdk.config.EmbeddedMessageConfig.EmbeddedMessageListener != null)
                        {
                            SwrveEmbeddedMessage embeddedMessage = ((SwrveEmbeddedCampaign)campaign).Message;
                            sdk.config.EmbeddedMessageConfig.EmbeddedMessageListener.OnMessage(embeddedMessage);
                        }
                        else
                        {
                            SwrveLog.LogError("Could not find a valid EmbeddedMessageListener defined as part of the EmbeddedMessageConfig, be sure that you did set it as parf of the SDK initialisation");
                        }
                    }
                    else
                    {
                        if (campaign is SwrveConversationCampaign)
                        {
                            SwrveConversationCampaign conversationCampaign = (SwrveConversationCampaign)campaign;
                            assetsQueue.UnionWith(conversationCampaign.Conversation.ConversationAssets);
                        }
                        else if (campaign is SwrveInAppCampaign)
                        {
                            SwrveInAppCampaign messageCampaign = (SwrveInAppCampaign)campaign;
                            assetsQueue.UnionWith(messageCampaign.GetImageAssets());
                        }
                        assetsManager.StartTask("SwrveAssetsManager.DownloadAssets", assetsManager.DownloadAssets(assetsQueue, AddCampaignToQueue, campaign));
                    }
                }
            } catch (Exception exp) {
                SwrveLog.LogError("Could not process ad journey campaign: " + exp.ToString());
            }
        }
    private void CheckAndAddCampaigns()
    {
        List <SwrveBaseCampaign>        campaigns  = SwrveComponent.Instance.SDK.GetMessageCenterCampaigns(SwrveOrientation.Both);
        IEnumerator <SwrveBaseCampaign> itCampaign = campaigns.GetEnumerator();

        while (itCampaign.MoveNext())
        {
            //Get the current campaign from iterator.
            SwrveBaseCampaign campaign = itCampaign.Current;

            //Check if this campaign is alrady available in scene.
            Transform campaignTransform = this.transform.Find(campaign.Subject + "-" + campaign.Id.ToString());

            //Just remove it from scene, if it CurStatus is "Deleted".
            if (campaign.State.CurStatus == SwrveCampaignState.Status.Deleted && campaignTransform != null)
            {
                GameObject.Destroy(transform.parent);
            }

            //Look if this campaign already was added on scene / If not create a new button for it.
            GameObject go;
            if (campaignTransform == null)
            {
                go = (GameObject)Instantiate(templateButtonGameObject);
                go.transform.SetParent(templateButtonGameObject.transform.parent);
                go.name = campaign.Subject + "-" + campaign.Id.ToString();
                go.transform.localScale = Vector3.one;
                go.SetActive(true);
            }
            else
            {
                go = campaignTransform.gameObject;
            }
            //Update the CampaignButton with campaign infos.
            go.GetComponent <SampleCampaignButton>().Setup(campaign);
        }
    }
Exemplo n.º 4
0
 public override void RemoveMessageCenterCampaign(SwrveBaseCampaign campaign)
 {
 }
Exemplo n.º 5
0
 public override void ShowMessageCenterCampaign(SwrveBaseCampaign campaign, SwrveOrientation orientation)
 {
 }
 public void setCampaign(SwrveBaseCampaign campaign)
 {
     this.campaign = campaign;
     updateCampaignInfo();
 }
        protected void AddCampaignToQueue(object campaignObject)
        {
            SwrveBaseCampaign campaign = (SwrveBaseCampaign)campaignObject;

            this.sdk.ShowCampaign(campaign, true);
        }
Exemplo n.º 8
0
 public override void MarkMessageCenterCampaignAsSeen(SwrveBaseCampaign campaign)
 {
 }
Exemplo n.º 9
0
 public override void ShowMessageCenterCampaign(SwrveBaseCampaign campaign, SwrveOrientation?orientation = null, Dictionary <string, string> properties = null)
 {
 }