-
Notifications
You must be signed in to change notification settings - Fork 71
feat: RoktContracts POC Core Changes #675
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
Open
BrandonStalnaker
wants to merge
14
commits into
workstation/9.0-Release
Choose a base branch
from
feat/RoktContracts-POC
base: workstation/9.0-Release
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
52a9b39
feat: RoktContracts POC Core Changes
BrandonStalnaker d382e22
automatically import RoktContracts library
BrandonStalnaker 1bb5b7c
kit changes and SwiftExample attempt
BrandonStalnaker 5eba563
Add Swift Extension
BrandonStalnaker 2481336
Update import to include mParticle core and RoktContracts as part of …
BrandonStalnaker 7327beb
Swift Example working
BrandonStalnaker e039bd1
Local cocoapods Example app finalized
BrandonStalnaker b568299
adjust for release
BrandonStalnaker e8ddc1b
Merge branch 'workstation/9.0-Release' into feat/RoktContracts-POC
BrandonStalnaker 50e02b7
address CR
BrandonStalnaker e1ac7d8
Address CR 2
BrandonStalnaker 433d788
Merge branch 'workstation/9.0-Release' into feat/RoktContracts-POC
BrandonStalnaker 78157c8
fix nil OnEvent issue
BrandonStalnaker 45d13e4
Merge branch 'workstation/9.0-Release' into feat/RoktContracts-POC
BrandonStalnaker 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
54 changes: 54 additions & 0 deletions
54
Kits/rokt/rokt/Sources/mParticle-Rokt-Swift/MPRokt+SwiftInterop.swift
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,54 @@ | ||
| import Foundation | ||
| import ObjectiveC | ||
| import mParticle_Apple_SDK | ||
| import RoktContracts | ||
|
|
||
| // Swift omits `events:onEvent:` and the full `selectPlacements:…onEvent:` from generated Swift API (RoktEvent block bridging). | ||
| extension MPRokt { | ||
| public func subscribeToPlacementEvents( | ||
| _ identifier: String, | ||
| onEvent: @escaping (RoktEvent) -> Void | ||
| ) { | ||
| typealias Block = @convention(block) (RoktEvent) -> Void | ||
| let sel = NSSelectorFromString("events:onEvent:") | ||
| guard let method = class_getInstanceMethod(MPRokt.self, sel) else { return } | ||
BrandonStalnaker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| let imp = method_getImplementation(method) | ||
| typealias Fn = @convention(c) (AnyObject, Selector, NSString, Block?) -> Void | ||
| unsafeBitCast(imp, to: Fn.self)(self, sel, identifier as NSString, onEvent as Block) | ||
| } | ||
|
|
||
| public func subscribeToGlobalEvents(_ onEvent: @escaping (RoktEvent) -> Void) { | ||
| typealias Block = @convention(block) (RoktEvent) -> Void | ||
| let sel = NSSelectorFromString("globalEvents:") | ||
| guard let method = class_getInstanceMethod(MPRokt.self, sel) else { return } | ||
| let imp = method_getImplementation(method) | ||
| typealias Fn = @convention(c) (AnyObject, Selector, Block) -> Void | ||
| unsafeBitCast(imp, to: Fn.self)(self, sel, onEvent as Block) | ||
| } | ||
|
|
||
| public func selectPlacements( | ||
| _ identifier: String, | ||
| attributes: [String: String], | ||
| embeddedViews: [String: RoktEmbeddedView]?, | ||
| config: RoktConfig?, | ||
| onEvent: ((RoktEvent) -> Void)? | ||
| ) { | ||
| typealias EventBlock = @convention(block) (RoktEvent) -> Void | ||
| let sel = NSSelectorFromString("selectPlacements:attributes:embeddedViews:config:onEvent:") | ||
| guard let method = class_getInstanceMethod(MPRokt.self, sel) else { return } | ||
| let imp = method_getImplementation(method) | ||
| typealias Fn = @convention(c) ( | ||
| AnyObject, | ||
| Selector, | ||
| NSString, | ||
| NSDictionary?, | ||
| NSDictionary?, | ||
| RoktConfig?, | ||
| EventBlock? | ||
| ) -> Void | ||
| let attrs = attributes as NSDictionary | ||
| let embedded = embeddedViews as NSDictionary? | ||
| let block: EventBlock? = onEvent.map { cb in cb as EventBlock } | ||
| unsafeBitCast(imp, to: Fn.self)(self, sel, identifier as NSString, attrs, embedded, config, block) | ||
| } | ||
| } | ||
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
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.