Skip to content

Commit

Permalink
Release Flutter SDK version 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hokstuff committed Dec 6, 2022
1 parent 5276be6 commit 5983286
Show file tree
Hide file tree
Showing 12 changed files with 662 additions and 514 deletions.
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"java.configuration.updateBuildConfiguration": "automatic",
"lldb.library": "/Applications/Xcode-14.0.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB",
"githubPullRequests.ignoredPullRequestBranches": [
"develop"
]
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
## 3.0.0

##### Breaking
- The native iOS bridge now uses the [new Braze Swift SDK](https://github.com/braze-inc/braze-swift-sdk), [version 5.6.4](https://github.com/braze-inc/braze-swift-sdk/blob/main/CHANGELOG.md#564).
- The minimum iOS deployment target is 10.0.
- During migration, update your project with the following changes:
- To initialize Braze, [follow these integration steps](https://braze-inc.github.io/braze-swift-sdk/tutorials/braze/a2-configure-braze) to create a `configuration` object. Then, add this code to complete the setup:
```
let braze = BrazePlugin.initBraze(configuration)
```
- To continue using `SDWebImage` as a dependency, add this line to your project's `/ios/Podfile`:
```
pod 'SDWebImage', :modular_headers => true
```
- Then, follow [these setup instructions](https://braze-inc.github.io/braze-swift-sdk/tutorials/braze/c3-gif-support).
- For guidance around other changes such as receiving in-app message and content card data, reference our sample [`AppDelegate.swift`](https://github.com/braze-inc/braze-flutter-sdk/blob/master/example/ios/Runner/AppDelegate.swift).
##### Added
- Adds the `isControl` field to `BrazeContentCard`.
##### Changed
- Updates the parameter syntax for `subscribeToInAppMessages()` and `subscribeToContentCards()`.
## 2.6.1
##### Added
Expand Down
6 changes: 4 additions & 2 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
platform :ios, '10.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down Expand Up @@ -28,9 +28,11 @@ require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelpe
flutter_ios_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

# Add this line to use the default image loader
pod 'SDWebImage', :modular_headers => true

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

Expand Down
43 changes: 18 additions & 25 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
EB2DDFF1B3E1144D693D4154 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FCD5C61F3CC6ED57C5740EF8 /* Pods_Runner.framework */; };
DA3B8E12704F8BFB709533C4 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BCDEDC224BBBA22EE83E5B26 /* libPods-Runner.a */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -49,15 +49,15 @@
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AA8109965AD879D827565410 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
FCD5C61F3CC6ED57C5740EF8 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
BCDEDC224BBBA22EE83E5B26 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
97C146EB1CF9000F007C117D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
EB2DDFF1B3E1144D693D4154 /* Pods_Runner.framework in Frameworks */,
DA3B8E12704F8BFB709533C4 /* libPods-Runner.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -67,7 +67,7 @@
0C8DAC57A8A97AA89DEBB028 /* Frameworks */ = {
isa = PBXGroup;
children = (
FCD5C61F3CC6ED57C5740EF8 /* Pods_Runner.framework */,
BCDEDC224BBBA22EE83E5B26 /* libPods-Runner.a */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down Expand Up @@ -150,7 +150,7 @@
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
F3BA121F9263BCB4B89FAB00 /* [CP] Embed Pods Frameworks */,
C63C0F1FBCC5E8F10BB33202 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -225,7 +225,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin\n";
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -239,30 +239,26 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n";
};
F3BA121F9263BCB4B89FAB00 /* [CP] Embed Pods Frameworks */ = {
C63C0F1FBCC5E8F10BB33202 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Appboy-iOS-SDK/Appboy_iOS_SDK.framework",
"${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework",
"${BUILT_PRODUCTS_DIR}/braze_plugin/braze_plugin.framework",
"${BUILT_PRODUCTS_DIR}/integration_test/integration_test.framework",
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh",
"${PODS_CONFIGURATION_BUILD_DIR}/BrazeKit/BrazeKit.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/BrazeUI/BrazeUI.bundle",
);
name = "[CP] Embed Pods Frameworks";
name = "[CP] Copy Pods Resources";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Appboy_iOS_SDK.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/braze_plugin.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/integration_test.framework",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/BrazeKit.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/BrazeUI.bundle",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
F49741450990356700E92D9D /* [CP] Check Pods Manifest.lock */ = {
Expand Down Expand Up @@ -360,7 +356,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -381,7 +377,6 @@
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -439,7 +434,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -486,7 +481,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand All @@ -509,7 +504,6 @@
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -539,7 +533,6 @@
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
Expand Down
94 changes: 65 additions & 29 deletions example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,49 +1,85 @@
import UIKit
import Appboy_iOS_SDK
import BrazeKit
import BrazeLocation
import BrazeUI
import Flutter
import SDWebImage
import UIKit
import braze_plugin

let apiKey = "9292484d-3b10-4e67-971d-ff0c0d518e21"
let brazeApiKey = "9292484d-3b10-4e67-971d-ff0c0d518e21"
let brazeEndpoint = "sondheim.appboy.com"

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate, ABKInAppMessageControllerDelegate {
@objc class AppDelegate: FlutterAppDelegate, BrazeInAppMessageUIDelegate {

static var braze: Braze? = nil

// The subscription needs to be retained to be active
var contentCardsSubscription: Braze.Cancellable?

override func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)

Appboy.start(withApiKey: apiKey,
in:application,
withLaunchOptions:launchOptions,
withAppboyOptions: [ABKMinimumTriggerTimeIntervalKey : 1,
ABKEnableSDKAuthenticationKey : true])
Appboy.sharedInstance()!.inAppMessageController.delegate = self
// - Setup Braze
let configuration = Braze.Configuration(apiKey: brazeApiKey, endpoint: brazeEndpoint)
configuration.sessionTimeout = 1
configuration.triggerMinimumTimeInterval = 0
configuration.location.automaticLocationCollection = true
configuration.location.brazeLocation = BrazeLocation()
configuration.logger.level = .debug

let braze = BrazePlugin.initBraze(configuration)

// - GIF support
GIFViewProvider.shared = .sdWebImage

// - InAppMessage UI
let inAppMessageUI = BrazeInAppMessageUI()
inAppMessageUI.delegate = self
braze.inAppMessagePresenter = inAppMessageUI

contentCardsSubscription = braze.contentCards.subscribeToUpdates { contentCards in
print("=> [Content Card Subscription] Received cards:", contentCards)

NotificationCenter.default.addObserver(self, selector: #selector(contentCardsUpdated), name:NSNotification.Name.ABKContentCardsProcessed, object: nil)
// Pass each content card model to the Dart layer.
BrazePlugin.processContentCards(contentCards)
}

return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}

func before(inAppMessageDisplayed inAppMessage: ABKInAppMessage) -> ABKInAppMessageDisplayChoice {
print("Received in-app message from Braze in beforeInAppMessageDisplayed delegate.")
// MARK: BrazeInAppMessageUIDelegate

// Pass in-app data to the Flutter layer.
BrazePlugin.processInAppMessage(inAppMessage)
func inAppMessage(
_ ui: BrazeInAppMessageUI,
willPresent message: Braze.InAppMessage,
view: InAppMessageView
) {
print("=> [In-app Message] Received message from Braze:", message)

// Note: return ABKInAppMessageDisplayChoice.discardInAppMessage if you would like
// to prevent the Braze SDK from displaying the message natively.
return ABKInAppMessageDisplayChoice.displayInAppMessageNow
// Pass in-app message data to the Dart layer.
BrazePlugin.processInAppMessage(message)
}

@objc private func contentCardsUpdated(_ notification: Notification) {
guard (notification.userInfo?[ABKContentCardsProcessedIsSuccessfulKey] as? Bool) == true,
let appboy = Appboy.sharedInstance() else {
return
}

// Pass in-app data to the Flutter layer.
let contentCards = appboy.contentCardsController.contentCards.compactMap { $0 as? ABKContentCard }
BrazePlugin.processContentCards(contentCards)
}

// MARK: GIF support

extension GIFViewProvider {

public static let sdWebImage = Self(
view: { SDAnimatedImageView(image: image(for: $0)) },
updateView: { ($0 as? SDAnimatedImageView)?.image = image(for: $1) }
)

private static func image(for url: URL?) -> UIImage? {
guard let url = url else { return nil }
return url.pathExtension == "gif"
? SDAnimatedImage(contentsOfFile: url.path)
: UIImage(contentsOfFile: url.path)
}

}
Loading

0 comments on commit 5983286

Please sign in to comment.