Skip to content

Commit a3d26b2

Browse files
authored
feat: Update Braze SDK, enable tvOS support, and clean up imports (#75)
1 parent 3a7fb07 commit a3d26b2

15 files changed

Lines changed: 645 additions & 237 deletions

File tree

AppboyTestHost/AppDelegate.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// AppDelegate.swift
3+
// AppboyTestHost
4+
//
5+
// Created by Ben Baron on 5/16/23.
6+
// Copyright © 2023 mParticle. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
@UIApplicationMain
12+
class AppDelegate: UIResponder, UIApplicationDelegate {
13+
14+
var window: UIWindow?
15+
16+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
17+
// Override point for customization after application launch.
18+
return true
19+
}
20+
}
21+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"platform" : "ios",
6+
"size" : "1024x1024"
7+
}
8+
],
9+
"info" : {
10+
"author" : "xcode",
11+
"version" : 1
12+
}
13+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7+
</dependencies>
8+
<scenes>
9+
<!--View Controller-->
10+
<scene sceneID="EHf-IW-A2E">
11+
<objects>
12+
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
13+
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
14+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
15+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16+
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
17+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
18+
</view>
19+
</viewController>
20+
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
21+
</objects>
22+
<point key="canvasLocation" x="53" y="375"/>
23+
</scene>
24+
</scenes>
25+
</document>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7+
</dependencies>
8+
<scenes>
9+
<!--View Controller-->
10+
<scene sceneID="tne-QT-ifu">
11+
<objects>
12+
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
13+
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
14+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
15+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16+
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
17+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
18+
</view>
19+
</viewController>
20+
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
21+
</objects>
22+
</scene>
23+
</scenes>
24+
</document>

AppboyTestHost/Info.plist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict/>
5+
</plist>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// ViewController.swift
3+
// AppboyTestHost
4+
//
5+
// Created by Ben Baron on 5/16/23.
6+
// Copyright © 2023 mParticle. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class ViewController: UIViewController {
12+
13+
override func viewDidLoad() {
14+
super.viewDidLoad()
15+
// Do any additional setup after loading the view.
16+
}
17+
18+
19+
}
20+

Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import PackageDescription
55

66
let package = Package(
77
name: "mParticle-Appboy",
8-
platforms: [ .iOS(.v9) ],
8+
platforms: [ .iOS(.v11), .tvOS(.v11) ],
99
products: [
1010
.library(
1111
name: "mParticle-Appboy",
@@ -17,14 +17,14 @@ let package = Package(
1717
.upToNextMajor(from: "8.0.0")),
1818
.package(name: "braze-swift-sdk",
1919
url: "https://github.com/braze-inc/braze-swift-sdk",
20-
.upToNextMajor(from: "5.9.0")),
20+
.upToNextMajor(from: "6.1.0")),
2121
],
2222
targets: [
2323
.target(
2424
name: "mParticle-Appboy",
2525
dependencies: [
2626
.byName(name: "mParticle-Apple-SDK"),
27-
.product(name: "BrazeUI", package: "braze-swift-sdk"),
27+
.product(name: "BrazeUI", package: "braze-swift-sdk", condition: .when(platforms: [.iOS])),
2828
.product(name: "BrazeKit", package: "braze-swift-sdk"),
2929
.product(name: "BrazeKitCompat", package: "braze-swift-sdk"),
3030
]

Sources/mParticle-Appboy/MPKitAppboy.m

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
#import "MPKitAppboy.h"
22

3-
#if SWIFT_PACKAGE
4-
#ifdef TARGET_OS_IOS
5-
@import BrazeKit;
6-
@import BrazeKitCompat;
7-
@import BrazeUI;
8-
#else
9-
@import BrazeKit;
10-
@import BrazeKitCompat;
11-
#endif
3+
#if TARGET_OS_IOS
4+
@import BrazeKit;
5+
@import BrazeKitCompat;
6+
@import BrazeUI;
127
#else
13-
#ifdef TARGET_OS_IOS
14-
@import BrazeKit;
15-
@import BrazeKitCompat;
16-
@import BrazeUI;
17-
#else
18-
@import BrazeKit;
19-
@import BrazeKitCompat;
20-
#endif
8+
@import BrazeKit;
9+
@import BrazeKitCompat;
2110
#endif
2211

2312
static NSString *const eabAPIKey = @"apiKey";
@@ -51,7 +40,7 @@
5140
// User Attribute key with reserved functionality for Braze kit
5241
static NSString *const brazeUserAttributeDob = @"dob";
5342

54-
#ifdef TARGET_OS_IOS
43+
#if TARGET_OS_IOS
5544
__weak static id<BrazeInAppMessageUIDelegate> inAppMessageControllerDelegate = nil;
5645
#endif
5746
__weak static id<BrazeDelegate> urlDelegate = nil;
@@ -79,7 +68,7 @@ + (void)load {
7968
[MParticle registerExtension:kitRegister];
8069
}
8170

82-
#ifdef TARGET_OS_IOS
71+
#if TARGET_OS_IOS
8372
+ (void)setInAppMessageControllerDelegate:(id)delegate {
8473
inAppMessageControllerDelegate = (id<BrazeInAppMessageUIDelegate>)delegate;
8574
}
@@ -169,13 +158,13 @@ - (MPKitExecStatus *)logAppboyCustomEvent:(MPEvent *)event eventType:(NSUInteger
169158
// Delete from array
170159
forwardUserAttributes = self.configuration[@"ear"];
171160
if (forwardUserAttributes[hashValue]) {
172-
[self->appboyInstance.user removeFromCustomAttributeArrayWithKey:forwardUserAttributes[hashValue] value:eventInfo[key]];
161+
[self->appboyInstance.user removeFromCustomAttributeStringArrayWithKey:forwardUserAttributes[hashValue] value:eventInfo[key]];
173162
}
174163

175164
// Add to array
176165
forwardUserAttributes = self.configuration[@"eaa"];
177166
if (forwardUserAttributes[hashValue]) {
178-
[self->appboyInstance.user addToCustomAttributeArrayWithKey:forwardUserAttributes[hashValue] value:eventInfo[key]];
167+
[self->appboyInstance.user addToCustomAttributeStringArrayWithKey:forwardUserAttributes[hashValue] value:eventInfo[key]];
179168
}
180169

181170
// Add key/value pair
@@ -302,7 +291,7 @@ - (void)start {
302291
[self->appboyInstance setAdTrackingEnabled:[self isAdvertisingTrackingEnabled]];
303292
}
304293

305-
#ifdef TARGET_OS_IOS
294+
#if TARGET_OS_IOS
306295
if ([MPKitAppboy inAppMessageControllerDelegate]) {
307296
BrazeInAppMessageUI *inAppMessageUI = [[BrazeInAppMessageUI alloc] init];
308297
inAppMessageUI.delegate = [MPKitAppboy inAppMessageControllerDelegate];
@@ -371,7 +360,7 @@ - (void)start {
371360
optionsDictionary[ABKSDKFlavorKey] = @(MPARTICLE);
372361
#pragma clang diagnostic pop
373362

374-
#ifdef TARGET_OS_IOS
363+
#if TARGET_OS_IOS
375364
optionsDictionary[ABKEnableAutomaticLocationCollectionKey] = @(YES);
376365
if (self.configuration[@"ABKDisableAutomaticLocationCollectionKey"]) {
377366
if ([self.configuration[@"ABKDisableAutomaticLocationCollectionKey"] caseInsensitiveCompare:@"true"] == NSOrderedSame) {
@@ -492,7 +481,7 @@ - (MPKitExecStatus *)logScreen:(MPEvent *)event {
492481
- (MPKitExecStatus *)receivedUserNotification:(NSDictionary *)userInfo {
493482
MPKitExecStatus *execStatus = [[MPKitExecStatus alloc] initWithSDKCode:@(MPKitInstanceAppboy) returnCode:MPKitReturnCodeSuccess];
494483

495-
#ifdef TARGET_OS_IOS
484+
#if TARGET_OS_IOS
496485
if (![appboyInstance.notifications handleBackgroundNotificationWithUserInfo:userInfo fetchCompletionHandler:^(UIBackgroundFetchResult fetchResult) {}]) {
497486
execStatus = [[MPKitExecStatus alloc] initWithSDKCode:@(MPKitInstanceAppboy) returnCode:MPKitReturnCodeFail];
498487
}
@@ -509,7 +498,7 @@ - (MPKitExecStatus *)removeUserAttribute:(NSString *)key {
509498
}
510499

511500
- (MPKitExecStatus *)setDeviceToken:(NSData *)deviceToken {
512-
#ifdef TARGET_OS_IOS
501+
#if TARGET_OS_IOS
513502
[appboyInstance.notifications registerDeviceToken:deviceToken];
514503
#endif
515504

@@ -862,7 +851,7 @@ - (MPKitExecStatus *)setUserIdentity:(NSString *)identityString identityType:(MP
862851
return [[MPKitExecStatus alloc] initWithSDKCode:@(MPKitInstanceAppboy) returnCode:MPKitReturnCodeSuccess];
863852
}
864853

865-
#ifdef TARGET_OS_IOS
854+
#if TARGET_OS_IOS
866855
- (nonnull MPKitExecStatus *)userNotificationCenter:(nonnull UNUserNotificationCenter *)center didReceiveNotificationResponse:(nonnull UNNotificationResponse *)response API_AVAILABLE(ios(10.0)) {
867856
MPKitExecStatus *execStatus = [[MPKitExecStatus alloc] initWithSDKCode:@(MPKitInstanceAppboy) returnCode:MPKitReturnCodeSuccess];
868857

0 commit comments

Comments
 (0)