-
Notifications
You must be signed in to change notification settings - Fork 0
refactor(rokt): move Rokt API out of core into the Rokt/Payments kits #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c55493d
refactor(rokt): move Rokt API out of core into the Rokt/Payments kits
denischilik c0dda89
ci: pin Xcode 26.2 and .NET MAUI workload set 10.0.103 for iOS builds
denischilik 9bbf70b
fix(rokt): route Shoppable Ads through the RoktApi receiver
denischilik 857e8a9
fix(loglevel): forward MParticleOptions.LogLevel to native SDKs
denischilik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| using Microsoft.Extensions.Logging; | ||
| using mParticle.MAUI; | ||
| using mParticle.MAUI.Rokt; | ||
|
|
||
| namespace SampleApp; | ||
|
|
||
|
|
||
105 changes: 105 additions & 0 deletions
105
Kits/rokt/Sdk/MParticle.Maui.Rokt.Payments/RoktShoppableAdsExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using mParticle.MAUI.Rokt; | ||
| #if __IOS__ | ||
| using System.Linq; | ||
| using Foundation; | ||
| using CoreBinding = global::mParticle.MAUI.iOSBinding; | ||
| #endif | ||
|
|
||
| namespace mParticle.MAUI.Rokt.Payments; | ||
|
|
||
| /// <summary> | ||
| /// Adds Shoppable Ads support to the Rokt API. This capability only exists when the | ||
| /// <c>mParticle.Maui.Kits.Rokt.Payments</c> package is referenced, because it depends on a | ||
| /// natively registered Rokt payment extension (see <see cref="RoktPaymentExtension"/>). | ||
| /// </summary> | ||
| public static class RoktShoppableAdsExtensions | ||
| { | ||
| /// <summary> | ||
| /// Displays a Shoppable Ads overlay placement. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Implemented on iOS (requires iOS 15+ and a payment extension registered via | ||
| /// <see cref="RoktPaymentExtension.Register(string, string)"/>). On Android this is a | ||
| /// no-op until native support lands. | ||
| /// </remarks> | ||
| /// <param name="rokt">The Rokt API instance.</param> | ||
| /// <param name="identifier">The view name / placement identifier.</param> | ||
| /// <param name="attributes">Optional attributes for targeting.</param> | ||
| /// <param name="config">Optional display configuration (color mode, caching).</param> | ||
| public static void SelectShoppableAds( | ||
| this RoktApi rokt, | ||
| string identifier, | ||
| Dictionary<string, string> attributes = null, | ||
|
Check warning on line 34 in Kits/rokt/Sdk/MParticle.Maui.Rokt.Payments/RoktShoppableAdsExtensions.cs
|
||
| RoktConfig config = null) | ||
|
Check warning on line 35 in Kits/rokt/Sdk/MParticle.Maui.Rokt.Payments/RoktShoppableAdsExtensions.cs
|
||
| { | ||
| // Route through the receiver's native handle so behavior matches the sibling | ||
| // RoktApi methods: a null handle means the SDK is not initialized (NoOp receiver). | ||
| var handle = rokt?.NativeHandle; | ||
| if (handle == null) | ||
| { | ||
| Console.WriteLine(RoktApi.SdkNotInitializedWarning); | ||
| return; | ||
| } | ||
| #if __IOS__ | ||
| if (handle is not CoreBinding.MPRokt native) | ||
| { | ||
| Console.WriteLine(RoktApi.SdkNotInitializedWarning); | ||
| return; | ||
| } | ||
|
|
||
| var nsAttributes = ConvertToNSDictionary(attributes) ?? new NSDictionary<NSString, NSString>(); | ||
| var nsConfig = ConvertToMpRoktConfig(config); | ||
|
|
||
| native.SelectShoppableAds(identifier, nsAttributes, nsConfig, null); | ||
| #else | ||
| Console.WriteLine("[mParticle MAUI SDK] SelectShoppableAds is not yet supported on Android."); | ||
| #endif | ||
| } | ||
|
|
||
| #if __IOS__ | ||
| private static CoreBinding.RoktConfig ConvertToMpRoktConfig(RoktConfig config) | ||
| { | ||
| if (config == null) | ||
| return null; | ||
|
|
||
| var builder = new CoreBinding.RoktConfigBuilder() | ||
| .ColorMode(ConvertToMpRoktColorMode(config.ColorMode)); | ||
|
|
||
| if (config.CacheDuration.HasValue || (config.CacheAttributes != null && config.CacheAttributes.Any())) | ||
| { | ||
| var cacheDuration = config.CacheDuration.HasValue | ||
| ? config.CacheDuration.Value | ||
| : CoreBinding.RoktCacheConfig.MaxCacheDuration; | ||
| var cacheAttributes = ConvertToNSDictionary(config.CacheAttributes); | ||
| var cacheConfig = new CoreBinding.RoktCacheConfig(cacheDuration, cacheAttributes); | ||
| builder = builder.CacheConfig(cacheConfig); | ||
| } | ||
|
|
||
| return builder.Build(); | ||
| } | ||
|
|
||
| private static CoreBinding.RoktColorMode ConvertToMpRoktColorMode(RoktColorMode colorMode) | ||
| { | ||
| switch (colorMode) | ||
| { | ||
| case RoktColorMode.Light: | ||
| return CoreBinding.RoktColorMode.Light; | ||
| case RoktColorMode.Dark: | ||
| return CoreBinding.RoktColorMode.Dark; | ||
| case RoktColorMode.System: | ||
| default: | ||
| return CoreBinding.RoktColorMode.System; | ||
| } | ||
| } | ||
|
|
||
| private static NSDictionary<NSString, NSString> ConvertToNSDictionary(Dictionary<string, string> dictionary) | ||
| { | ||
| if (dictionary == null || !dictionary.Any()) | ||
| return new NSDictionary<NSString, NSString>(); | ||
|
|
||
| return NSDictionary<NSString, NSString>.FromObjectsAndKeys(dictionary.Values.ToArray(), dictionary.Keys.ToArray()); | ||
| } | ||
| #endif | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| using mParticle.MAUI; | ||
|
|
||
| namespace mParticle.MAUI.Rokt; | ||
|
|
||
| /// <summary> | ||
| /// Adds the Rokt entry point to the mParticle SDK. The <c>Rokt</c> accessor only exists | ||
| /// when the <c>mParticle.Maui.Kits.Rokt</c> package is referenced; the core SDK does not | ||
| /// expose any Rokt surface on its own. | ||
| /// </summary> | ||
| public static class MParticleRoktExtensions | ||
| { | ||
| extension(MParticleSDK sdk) | ||
| { | ||
| /// <summary> | ||
| /// Returns an implementation of the Rokt API bound to the current mParticle instance. | ||
| /// </summary> | ||
| public RoktApi Rokt | ||
| { | ||
| get | ||
| { | ||
| if (sdk == null) | ||
| { | ||
| return new NoOpRoktApi(); | ||
| } | ||
| #if __IOS__ | ||
| var native = sdk.GetBindingInstance() as mParticle.MAUI.iOSBinding.MParticle; | ||
| var rokt = native?.Rokt; | ||
| return rokt == null ? new NoOpRoktApi() : new IosRoktApi(rokt); | ||
| #elif __ANDROID__ | ||
| var native = sdk.GetBindingInstance() as mParticle.MAUI.AndroidBinding.MParticle; | ||
| return native == null ? new NoOpRoktApi() : new AndroidRoktApi(native); | ||
| #else | ||
| return new NoOpRoktApi(); | ||
| #endif | ||
| } | ||
|
denischilik marked this conversation as resolved.
|
||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.