private async void InitConsent()
        {
            ConsentInformation consentInformation = ConsentInformation.GetInstance(ApplicationContext);

            String[] publisherIds = { BaseContext.GetString(Resource.String.admob_publisher_id) };
            await consentInformation.RequestConsentInfoUpdate(publisherIds,
                                                              (consentStatus) =>
            {
                Log.Info(TAG, "Status = " + consentStatus.ToString());
                LoadConsentForm();
            },
                                                              (msg) =>
            {
                Log.Error(TAG, msg);
            }
                                                              );
        }
        public void CommunicationProfile_FacetExists_ShouldReturnContactCommunicationProfile([NoAutoProperties] ContactFacetsProvider provider, IXConnectFacets facets, ConsentInformation facet, ITracker tracker, [Substitute] Contact contact)
        {
            // Arrange
            tracker.IsActive.Returns(true);
            tracker.Contact.Returns(contact);
            facets.Facets.Returns(new ReadOnlyDictionary <string, Facet>(new Dictionary <string, Facet>
            {
                {
                    ConsentInformation.DefaultFacetKey, facet
                }
            }));
            contact.GetFacet <IXConnectFacets>("XConnectFacets").Returns(facets);

            using (new TrackerSwitcher(tracker))
            {
                // Act
                var profile = provider.CommunicationProfile;

                // Assert
                profile.Should().NotBeNull();
                profile.Should().BeEquivalentTo(facet);
            }
        }
 protected override IBindingHandlerResult GetFieldBindingValueFromFacet(ConsentInformation facet)
 {
     return(new BindingValueFoundResult(facet.DoNotMarket));
 }
Beispiel #4
0
 protected override IFieldValueBinderResult GetFieldBindingValueFromFacet(ConsentInformation facet)
 {
     return(new FieldValueBindingFoundResult(facet.ExecutedRightToBeForgotten));
 }
        private void SetContact(Contact target, Contact source)
        {
            // Default Facets
            if (source.Facets.ContainsKey(PersonalInformation.DefaultFacetKey))
            {
                if (target.Facets.ContainsKey(PersonalInformation.DefaultFacetKey))
                {
                    PersonalInformation sourceFacet = source.GetFacet <PersonalInformation>();
                    PersonalInformation targetFacet = target.GetFacet <PersonalInformation>();
                    targetFacet.Birthdate         = sourceFacet.Birthdate;
                    targetFacet.FirstName         = sourceFacet.FirstName;
                    targetFacet.Gender            = sourceFacet.Gender;
                    targetFacet.JobTitle          = sourceFacet.JobTitle;
                    targetFacet.Title             = sourceFacet.Title;
                    targetFacet.LastName          = sourceFacet.LastName;
                    targetFacet.MiddleName        = sourceFacet.MiddleName;
                    targetFacet.Nickname          = sourceFacet.Nickname;
                    targetFacet.PreferredLanguage = sourceFacet.PreferredLanguage;
                    targetFacet.Suffix            = sourceFacet.Suffix;
                    _client.SetFacet(target, PersonalInformation.DefaultFacetKey, targetFacet);
                }
                else
                {
                    _client.SetFacet(
                        target,
                        PersonalInformation.DefaultFacetKey,
                        source.GetFacet <PersonalInformation>().WithClearedConcurrency());
                }
            }

            if (source.Facets.ContainsKey(EmailAddressList.DefaultFacetKey))
            {
                if (target.Facets.ContainsKey(EmailAddressList.DefaultFacetKey))
                {
                    EmailAddressList sourceFacet = source.GetFacet <EmailAddressList>();
                    EmailAddressList targetFacet = target.GetFacet <EmailAddressList>();
                    targetFacet.Others         = sourceFacet.Others;
                    targetFacet.PreferredEmail = sourceFacet.PreferredEmail;
                    targetFacet.PreferredKey   = sourceFacet.PreferredKey;
                    _client.SetFacet(target, EmailAddressList.DefaultFacetKey, targetFacet);
                }
                else
                {
                    _client.SetFacet(
                        target,
                        EmailAddressList.DefaultFacetKey,
                        source.GetFacet <EmailAddressList>().WithClearedConcurrency());
                }
            }

            if (source.Facets.ContainsKey(AddressList.DefaultFacetKey))
            {
                if (target.Facets.ContainsKey(AddressList.DefaultFacetKey))
                {
                    AddressList sourceFacet = source.Addresses();
                    AddressList targetFacet = target.Addresses();
                    targetFacet.PreferredKey     = sourceFacet.PreferredKey;
                    targetFacet.Others           = sourceFacet.Others;
                    targetFacet.PreferredAddress = sourceFacet.PreferredAddress;
                    _client.SetAddresses(target, targetFacet);
                }
                else
                {
                    _client.SetAddresses(target, source.Addresses().WithClearedConcurrency());
                }
            }

            if (source.Facets.ContainsKey(PhoneNumberList.DefaultFacetKey))
            {
                if (target.Facets.ContainsKey(PhoneNumberList.DefaultFacetKey))
                {
                    PhoneNumberList sourceFacet = source.PhoneNumbers();
                    PhoneNumberList targetFacet = target.PhoneNumbers();
                    targetFacet.PreferredKey         = sourceFacet.PreferredKey;
                    targetFacet.Others               = sourceFacet.Others;
                    targetFacet.PreferredPhoneNumber = sourceFacet.PreferredPhoneNumber;
                    _client.SetPhoneNumbers(target, targetFacet);
                }
                else
                {
                    _client.SetPhoneNumbers(target, source.PhoneNumbers().WithClearedConcurrency());
                }
            }

            if (source.Facets.ContainsKey(ConsentInformation.DefaultFacetKey))
            {
                if (target.Facets.ContainsKey(ConsentInformation.DefaultFacetKey))
                {
                    ConsentInformation sourceFacet = source.ConsentInformation();
                    ConsentInformation targetFacet = target.ConsentInformation();
                    targetFacet.ConsentRevoked             = sourceFacet.ConsentRevoked;
                    targetFacet.DoNotMarket                = sourceFacet.DoNotMarket;
                    targetFacet.ExecutedRightToBeForgotten = sourceFacet.ExecutedRightToBeForgotten;
                    _client.SetConsentInformation(target, targetFacet);
                }
                else
                {
                    _client.SetConsentInformation(target, source.ConsentInformation().WithClearedConcurrency());
                }
            }

            if (source.Facets.ContainsKey(ListSubscriptions.DefaultFacetKey))
            {
                if (target.Facets.ContainsKey(ListSubscriptions.DefaultFacetKey))
                {
                    ListSubscriptions sourceFacet = source.ListSubscriptions();
                    ListSubscriptions targetFacet = target.ListSubscriptions();
                    targetFacet.Subscriptions = sourceFacet.Subscriptions;
                    _client.SetListSubscriptions(target, targetFacet);
                }
                else
                {
                    _client.SetListSubscriptions(target, source.ListSubscriptions().WithClearedConcurrency());
                }
            }

            if (source.Facets.ContainsKey(Avatar.DefaultFacetKey))
            {
                if (target.Facets.ContainsKey(Avatar.DefaultFacetKey))
                {
                    Avatar sourceFacet = source.Avatar();
                    Avatar targetFacet = target.Avatar();
                    targetFacet.MimeType = sourceFacet.MimeType;
                    targetFacet.Picture  = sourceFacet.Picture;
                    _client.SetAvatar(target, targetFacet);
                }
                else
                {
                    _client.SetAvatar(target, source.Avatar().WithClearedConcurrency());
                }
            }

            if (source.Facets.ContainsKey(EmailAddressHistory.DefaultFacetKey))
            {
                if (target.Facets.ContainsKey(EmailAddressHistory.DefaultFacetKey))
                {
                    EmailAddressHistory sourceFacet = source.GetFacet <EmailAddressHistory>();
                    EmailAddressHistory targetFacet = target.GetFacet <EmailAddressHistory>();
                    targetFacet.History = sourceFacet.History;
                    _client.SetFacet(target, EmailAddressHistory.DefaultFacetKey, targetFacet);
                }
                else
                {
                    _client.SetFacet(
                        target,
                        EmailAddressHistory.DefaultFacetKey,
                        source.GetFacet <EmailAddressHistory>().WithClearedConcurrency());
                }
            }

            if (source.Facets.ContainsKey("TestCombinations"))
            {
                if (target.Facets.ContainsKey("TestCombinations"))
                {
                    TestCombinationsData sourceFacet = source.Facets["TestCombinations"] as TestCombinationsData;
                    if (target.Facets["TestCombinations"] is TestCombinationsData targetFacet)
                    {
                        targetFacet.TestCombinations = sourceFacet?.TestCombinations;
                        _client.SetFacet(target, "TestCombinations", targetFacet);
                    }
                }
                else
                {
                    Facet oldFacet = source.Facets["TestCombinations"];
                    TestCombinationsData newFacet = new TestCombinationsData();
                    newFacet.TestCombinations = oldFacet.XObject["TestCombinations"]?.ToString();
                    _client.SetFacet(target, "TestCombinations", newFacet);
                }
            }

            // TODO Handle custom facets

            _client.Submit();
        }
 protected override IBindingHandlerResult GetFieldBindingValueFromFacet(ConsentInformation facet)
 {
     return new BindingValueFoundResult(facet.ExecutedRightToBeForgotten);
 }
 protected override IFieldValueBinderResult GetFieldBindingValueFromFacet(ConsentInformation facet)
 {
     return(new FieldValueBindingFoundResult(facet.ConsentRevoked));
 }