Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// swift-tools-version:5.5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "mParticle-Apptentive",
platforms: [ .iOS(.v13) ],
products: [
.library(
name: "mParticle-Apptentive",
targets: ["mParticle-Apptentive"]),
],
dependencies: [
.package(name: "mParticle-Apple-SDK",
url: "https://github.com/mParticle/mparticle-apple-sdk",
.upToNextMajor(from: "8.0.0")),
.package(name: "ApptentiveKit",
url: "https://github.com/apptentive/apptentive-kit-ios",
.upToNextMajor(from: "6.0.0")),
],
targets: [
.target(
name: "mParticle-Apptentive",
dependencies: [
.byName(name: "mParticle-Apple-SDK"),
.byName(name: "ApptentiveKit")
],
path: "./mParticle-Apptentive",
exclude: ["Info.plist"]
)
]
)
10 changes: 6 additions & 4 deletions mParticle-Apptentive/MPKitApptentive.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#if defined(__has_include) && __has_include(<ApptentiveKit/ApptentiveKit-Swift.h>)
#import <ApptentiveKit/ApptentiveKit-Swift.h>
#elif defined(__has_include) && __has_include(ApptentiveKit-Swift.h)
#import "ApptentiveKit-Swift.h"
#else
@import ApptentiveKit;
#endif
Expand Down Expand Up @@ -270,10 +268,14 @@ - (nonnull MPKitExecStatus *)logBaseEvent:(nonnull MPBaseEvent *)event {

- (MPKitExecStatus *)routeEvent:(MPEvent *)event {
NSDictionary *eventValues = event.customAttributes;

UIViewController * rootViewController = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
Copy link
Copy Markdown
Contributor

@frankus frankus Feb 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be missing something, but this case should already be handled by the Apptentive SDK.

Passing nil results in a nil presentingViewController property on the InteractionPresenter instance (see https://github.com/apptentive/apptentive-kit-ios/blob/97ba45ba650f742be956a5e33fc1c4f31a626574/Sources/ApptentiveKit/Interactions/InteractionPresenter.swift#L168), which will walk up the view controller stack of the application's keyWindow. It also handles the (surprisingly common) case where an interaction tries to present on a view controller that is being dismissed.



if ([eventValues count] > 0) {
[Apptentive.shared engage:event.name withCustomData:[self parseEventInfoDictionary:eventValues] fromViewController:nil];
[Apptentive.shared engage:event.name withCustomData:[self parseEventInfoDictionary:eventValues] fromViewController:rootViewController];
} else {
[Apptentive.shared engage:event.name fromViewController:nil];
[Apptentive.shared engage:event.name fromViewController:rootViewController];
}
return [self execStatus:MPKitReturnCodeSuccess];
}
Expand Down