Skip to content

Commit

Permalink
MobileCore.registerEventListener enhancement (#559)
Browse files Browse the repository at this point in the history
* update public API: registerEventListener

* update the test project and do some manual tests for public API -> registerEventListener

* update Podfile.lock

* format
  • Loading branch information
yangyansong-adbe authored Mar 4, 2021
1 parent d3d244d commit 50829b3
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 345 deletions.
10 changes: 7 additions & 3 deletions AEPCore/Sources/core/MobileCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,18 @@ public final class MobileCore: NSObject {
EventHub.shared.dispatch(event: event)
}

/// Registers an `EventListener` which will be invoked whenever a event with matched type and source is dispatched
/// Registers an `EventListener` to perform on the global system queue (Qos = .default) which will be invoked whenever an event with matched type and source is dispatched.
/// - Parameters:
/// - type: A `String` indicating the event type the current listener is listening for
/// - source: A `String` indicating the event source the current listener is listening for
/// - listener: An `EventResponseListener` which will be invoked whenever the `EventHub` receives a event with matched type and source
/// - listener: An `EventResponseListener` which will be invoked whenever the `EventHub` receives an event with matched type and source.
@objc(registerEventListenerWithType:source:listener:)
public static func registerEventListener(type: String, source: String, listener: @escaping EventListener) {
EventHub.shared.registerEventListener(type: type, source: source, listener: listener)
EventHub.shared.registerEventListener(type: type, source: source) { event in
DispatchQueue.global(qos: .default).async {
listener(event)
}
}
}

/// Submits a generic event containing the provided IDFA with event type `generic.identity`.
Expand Down
2 changes: 1 addition & 1 deletion AEPServices/Sources/ui/fullscreen/FullscreenMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public class FullscreenMessage: NSObject, WKNavigationDelegate, FullscreenPresen
private func getConfiguredWebview(newFrame: CGRect) -> WKWebView {
let webViewConfiguration = WKWebViewConfiguration()

//Fix for media playback.
// Fix for media playback.
webViewConfiguration.allowsInlineMediaPlayback = true // Plays Media inline
webViewConfiguration.mediaTypesRequiringUserActionForPlayback = []
let wkWebView = WKWebView(frame: newFrame, configuration: webViewConfiguration)
Expand Down
2 changes: 2 additions & 0 deletions AEPServices/Sources/utility/unzip/URL+Validator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
governing permissions and limitations under the License.
*/

import Foundation

extension URL {
///
/// Validates a URL against a Zip Slip attack. Simply checks if there is any sort of traversal attempted in the url
Expand Down
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 31a9899de6250afde3d420f3c919cf16beb8dc75

COCOAPODS: 1.10.0
COCOAPODS: 1.10.1
419 changes: 80 additions & 339 deletions TestApps/AEPCoreTestApp.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"repositoryURL": "https://github.com/adobe/aepsdk-rulesengine-ios.git",
"state": {
"branch": "main",
"revision": "8815389caf92bd8886b72e9e4e1cb05176cb2767",
"revision": "1e270654b330b9f07a6b1ec374e686f2e631e039",
"version": null
}
}
Expand Down
20 changes: 20 additions & 0 deletions TestApps/PerformanceApp/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,26 @@ struct ContentView: View {
usleep(100)
}
}
// let type = "test.type"
// let source = "test.source"
// MobileCore.registerEventListener(type: type, source: source){event in
// while (true){
// print("sleep for 2 seconds.")
// sleep(2)
// }
// }
// MobileCore.registerEventListener(type: type, source: source){event in
// if let dataValue = event.data?["key"] as? String {
// print("==== \(dataValue)")
// }else{
// print("==== data key not exists")
// }
// }
// for n in 0..<10{
// MobileCore.dispatch(event: Event(name: "test event", type: type, source: source, data:
// ["key":"value_\(n)"]))
// }

}) {
Text("Evaluate Rules")
.frame(minWidth: 0, maxWidth: .infinity)
Expand Down

0 comments on commit 50829b3

Please sign in to comment.