Skip to content

Commit

Permalink
release: SDK 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-roland committed Apr 26, 2024
1 parent d0eb6ce commit 6ac4230
Show file tree
Hide file tree
Showing 187 changed files with 5,960 additions and 4,775 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ let package = Package(
targets: [
.binaryTarget(
name: "Batch",
url: "https://download.batch.com/sdk/ios/spm/BatchSDK-ios_spm-xcframework-1.21.2.zip",
checksum: "5caa61a570d8317f4f5a75e4325c2bfcbc5f9b98349bffd5c2fc21375755da25"
url: "https://download.batch.com/sdk/ios/spm/BatchSDK-ios_spm-xcframework-2.0.0.zip",
checksum: "9e78ad2e7320d91a9b1b3ca8f2069f260cf96d6d93309e9d5504f2b551ecbda2"
)
]
)
362 changes: 257 additions & 105 deletions Sources/Batch.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
LastUpgradeVersion = "1520"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
LastUpgradeVersion = "1520"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
LastUpgradeVersion = "1520"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
LastUpgradeVersion = "1520"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
LastUpgradeVersion = "1520"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
1 change: 0 additions & 1 deletion Sources/Batch/BAErrorHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ typedef NS_ENUM(NSInteger, BAInternalFailReason) {
*/
BAInternalFailReasonOptedOut = -60
};
typedef NSInteger BatchFailReason;

/*!
@class BAErrorHelper
Expand Down
5 changes: 4 additions & 1 deletion Sources/Batch/Batch.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ FOUNDATION_EXPORT const unsigned char BatchVersionString[];

#import <Batch/BatchActions.h>
#import <Batch/BatchCore.h>
#import <Batch/BatchEventData.h>
#import <Batch/BatchDataCollectionConfig.h>
#import <Batch/BatchEventAttributes.h>
#import <Batch/BatchEventDispatcher.h>
#import <Batch/BatchInbox.h>
#import <Batch/BatchLogger.h>
#import <Batch/BatchMessaging.h>
#import <Batch/BatchMessagingModels.h>
#import <Batch/BatchProfile.h>
#import <Batch/BatchProfileEditor.h>
#import <Batch/BatchPush.h>
#import <Batch/BatchUser.h>
#import <Batch/BatchUserAttribute.h>
10 changes: 8 additions & 2 deletions Sources/Batch/Batch.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ framework module Batch {

explicit module Core {
header "BatchCore.h"
header "BatchUserProfile.h"
header "BatchDataCollectionConfig.h"
export *
}

explicit module Profile {
header "BatchProfile.h"
header "BatchProfileEditor.h"
header "BatchEventAttributes.h"
export *
}

Expand Down Expand Up @@ -39,7 +46,6 @@ framework module Batch {

explicit module User {
header "BatchUser.h"
header "BatchEventData.h"
header "BatchUserAttribute.h"
export *
}
Expand Down
5 changes: 1 addition & 4 deletions Sources/Batch/BatchActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ typedef void (^BatchUserActionBlock)(NSString *_Nonnull identifier,
@end

/// BatchActions error code constants.
enum {
typedef NS_ENUM(NSInteger, BatchActionError) {

/// Internal error
BatchActionErrorUnknown = -1001,
Expand All @@ -101,6 +101,3 @@ enum {
/// This action identifier is reserved and cannot be used. Note that actions cannot begin by "batch."
BatchActionErrorReservedIdentifier = -1003
};

/// @typedef BatchActionError
typedef NSInteger BatchActionError;
129 changes: 69 additions & 60 deletions Sources/Batch/BatchCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
// Copyright (c) Batch SDK. All rights reserved.
//

#import <Batch/BatchDataCollectionConfig.h>
#import <Batch/BatchLogger.h>
#import <Batch/BatchUserProfile.h>

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

Expand All @@ -22,8 +23,23 @@ typedef NS_ENUM(NSUInteger, BatchOptOutNetworkErrorPolicy) {
BatchOptOutNetworkErrorPolicyCancel,
};

/// Batch migrations types
typedef NS_OPTIONS(NSUInteger, BatchMigration) {
/// No migrations disabled
BatchMigrationNone = 0,

/// Whether Bath should automatically identify logged-in user when running the SDK v2 for the first time.
/// This mean user with a custom_user_id will be automatically attached a to a Profile and can be targeted within a
/// Project scope.
BatchMigrationCustomID = 1 << 0,

/// Whether Bath should automatically attach current installation's data (language/region/customDataAttributes...)
/// to the User's Profile when running the SDK v2 for the first time.
BatchMigrationCustomData = 1 << 1,
};

/// Batch's main entry point.
@interface Batch : NSObject
@interface BatchSDK : NSObject

/// Use the deeplink delegate object to process deeplink open requests from Batch.
///
Expand Down Expand Up @@ -55,58 +71,20 @@ typedef NS_ENUM(NSUInteger, BatchOptOutNetworkErrorPolicy) {
/// - key: Your APP's API Key, LIVE or DEV. You can find it on your dashboard.
+ (void)startWithAPIKey:(NSString *_Nonnull)key;

/// Handles an URL, if applicable.
///
/// Call this method in `application:openURL:sourceApplication:annotation:` of your `UIApplicationDelegate`
/// - Parameters:
/// - url: The URL given to you by iOS
/// - Returns: YES if Batch performed an action with this URL, NO otherwise.
+ (BOOL)handleURL:(NSURL *_Nonnull)url __attribute__((warn_unused_result))NS_AVAILABLE_IOS(8_0);

/// Check if Batch is running in development mosde.
///
/// - Returns: YES if Batch is started __AND__ if it uses a development API key.
+ (BOOL)isRunningInDevelopmentMode __attribute__((warn_unused_result))NS_AVAILABLE_IOS(8_0);

/// Access the default user profile object.
///
/// - Deprecated: Please use Batch User instead
/// - Returns: An instance of ``BatchUserProfile``, or nil
+ (BatchUserProfile *_Nullable)defaultUserProfile
__attribute__((warn_unused_result, deprecated("Please use Batch User instead")))NS_AVAILABLE_IOS(8_0);

/// As Batch has removed support for automatic IDFA collection, this method does nothing. The SDK will not collect the
/// IDFA from the system.
/// - Warning: This method has been deprecated
/// - Parameters:
/// - use: This parameter doesn't do anything
+ (void)setUseIDFA:(BOOL)use __attribute__((deprecated));

/// Set if Batch can use advanced device identifiers (default = YES)
///
/// Advanced device identifiers include information about the device itself, but nothing that directly identify the
/// user, such as but not limited to:
/// - Device model
/// - Device brand
/// - Carrier name
/// - Parameters:
/// - use: YES if Batch can try to use advanced device information, NO if you don't
+ (void)setUseAdvancedDeviceInformation:(BOOL)use;

/// Set if Batch should send its logs to a custom object of yours.
///
/// - Important: Be careful with your implementation: setting this can impact stability and performance. You should only
/// use it if you know what you are doing.
/// - Parameter loggerDelegate: An object implementing ``Batch/BatchLoggerDelegate``. Weakly retained.
+ (void)setLoggerDelegate:(id<BatchLoggerDelegate> _Nullable)loggerDelegate;
@property (class, nullable) id<BatchLoggerDelegate> loggerDelegate;

/// Get the debug view controller.
///
/// For development purposes only, this contains UI with multiple debug features allowing you to debug your Batch
/// implementation more easily. If you want to make it accessible in production, you should hide it in a hard to
/// reproduce sequence.
/// - Note: Should be presented modally.
+ (UIViewController *_Nullable)debugViewController;
+ (UIViewController *_Nullable)makeDebugViewController;

/// Toogle whether internal logs should be logged or not.
///
Expand All @@ -117,20 +95,33 @@ typedef NS_ENUM(NSUInteger, BatchOptOutNetworkErrorPolicy) {
/// - Parameter enableInternalLogs: Whether to enable development logs. Default: false (unless enabled via CLI).
+ (void)setInternalLogsEnabled:(BOOL)enableInternalLogs;

/// Configure the SDK Automatic Data Collection.
///
/// - Parameter editor: A block that will be called with an instance of the automatic data collection configuration as a
/// parameter. Modify the instance of the config to fine-tune the data you authorize to be tracked by Batch.
/// - Note: Batch will persist the changes, so you can call this method at any time according to user consent.
/// ```swift
/// Batch.updateAutomaticDataCollection { config in
/// config.setGeoIPEnabled(false) // Deny Batch from resolving the user's region from the ip address.
/// config.setDeviceModelEnabled(true) // Authorize Batch to use the user's device model information.
/// }
/// ```
+ (void)updateAutomaticDataCollection:(_Nonnull BatchDataCollectionConfigEditor)editor;

/// Opt-out from Batch SDK usage.
///
/// - Important: Calling this method when Batch hasn't started does nothing: Please call
/// ``Batch/Batch/startWithAPIKey:`` beforehand.
/// ``Batch/BatchSDK/startWithAPIKey:`` beforehand.
///
/// A push opt-out command will be sent to Batch's servers if the user is connected to the internet.
/// If disconnected, notifications might not be disabled properly. Please use
/// ``Batch/Batch/optOutWithCompletionHandler:`` to handle these cases more gracefully.
/// ``Batch/BatchSDK/optOutWithCompletionHandler:`` to handle these cases more gracefully.
///
/// Your app should be prepared to handle these cases. Some modules might behave unexpectedly when the SDK is opted out
/// from.
///
/// Opting out will:
/// - Prevent ``Batch/Batch/startWithAPIKey:`` from starting the SDK
/// - Prevent ``Batch/BatchSDK/startWithAPIKey:`` from starting the SDK
/// - Disable any network capability from the SDK
/// - Disable all In-App campaigns
/// - Make the Inbox module return an error immediatly
Expand All @@ -140,30 +131,30 @@ typedef NS_ENUM(NSUInteger, BatchOptOutNetworkErrorPolicy) {
/// Even if you opt-in afterwards, data generated (such as user data or tracked events) while opted out __WILL__ be
/// lost.
///
/// If you also want to delete user data, please see ``Batch/Batch/optOutAndWipeData``.
/// If you also want to delete user data, please see ``Batch/BatchSDK/optOutAndWipeData``.
+ (void)optOut;

/// Opt-out from Batch SDK and wipe data.
///
/// - Important: Calling this method when Batch hasn't started does nothing: Please call
/// ``Batch/Batch/startWithAPIKey:`` beforehand test.
/// ``Batch/BatchSDK/startWithAPIKey:`` beforehand test.
///
/// An installation data wipe command will be sent to Batch's servers if the user is connected to the internet.
/// If disconnected, notifications might not be disabled properly. Please use
/// ``Batch/Batch/optOutAndWipeDataWithCompletionHandler:`` to handle these cases more gracefully.
/// ``Batch/BatchSDK/optOutAndWipeDataWithCompletionHandler:`` to handle these cases more gracefully.
///
/// See ``Batch/Batch/optOut`` documentation for details.
/// See ``Batch/BatchSDK/optOut`` documentation for details.
///
/// - Note: Once opted out, ``Batch/Batch/startWithAPIKey:`` will essentially be a no-op. Your app should be prepared to
/// handle these cases.
/// - Note: Once opted out, ``Batch/BatchSDK/startWithAPIKey:`` will essentially be a no-op. Your app should be prepared
/// to handle these cases.
+ (void)optOutAndWipeData;

/// Opt-out from Batch SDK.
///
/// - Important: Calling this method when Batch hasn't started does nothing: Please call
/// ``Batch/Batch/startWithAPIKey:`` beforehand test.
/// ``Batch/BatchSDK/startWithAPIKey:`` beforehand test.
///
/// See ``Batch/Batch/optOut`` documentation for details.
/// See ``Batch/BatchSDK/optOut`` documentation for details.
///
/// Use the completion handler to be informed about whether the opt-out request has been successfully sent to the server
/// or not. You'll also be able to control what to do in case of failure.
Expand All @@ -177,9 +168,9 @@ typedef NS_ENUM(NSUInteger, BatchOptOutNetworkErrorPolicy) {
/// Opt-out from Batch SDK and wipe data.
///
/// - Important: Calling this method when Batch hasn't started does nothing: Please call
/// ``Batch/Batch/startWithAPIKey:`` beforehand test.
/// ``Batch/BatchSDK/startWithAPIKey:`` beforehand test.
///
/// See ``Batch/Batch/optOut`` documentation for details.
/// See ``Batch/BatchSDK/optOut`` documentation for details.
///
/// Use the completion handler to be informed about whether the opt-out request has been successfully sent to the server
/// or not. You'll also be able to control what to do in case of failure.
Expand All @@ -192,13 +183,13 @@ typedef NS_ENUM(NSUInteger, BatchOptOutNetworkErrorPolicy) {

/// Opt-in to Batch SDK.
///
/// Useful if you called ``Batch/Batch/optOut``, ``Batch/Batch/optOutAndWipeData`` or opted out by default in your
/// Useful if you called ``Batch/BatchSDK/optOut``, ``Batch/BatchSDK/optOutAndWipeData`` or opted out by default in your
/// Info.plist.
/// - Important: You will need to call ``Batch/Batch/startWithAPIKey:`` after this.
/// - Important: You will need to call ``Batch/BatchSDK/startWithAPIKey:`` after this.
+ (void)optIn;

/// Returns whether Batch has been opted out from or not
+ (BOOL)isOptedOut;
@property (readonly, class) BOOL isOptedOut;

/// Set your list of associated domains, If your app handle universal links.
///
Expand All @@ -208,13 +199,31 @@ typedef NS_ENUM(NSUInteger, BatchOptOutNetworkErrorPolicy) {
/// - Important: Make sure to only include the desired subdomain and the top-level domain. Don’t include path and query
/// components or a trailing slash (/).
/// - Parameter domains: An array of your supported associated domains.
+ (void)setAssociatedDomains:(NSArray<NSString *> *_Nonnull)domains;
@property (class, nonnull) NSArray<NSString *> *associatedDomains;

/// Set data migrations you want to disable.
///
/// - Important: Make sure to call this method before ``Batch/BatchSDK/startWithAPIKey:``.
/// - Parameter migrations: migrations to disable
///
/// ## Examples:
/// ```swift
/// /// Swift
/// /// Disabling custom ID and Data migrations
/// BatchSDK.setDisabledMigrations([.customID, .customData])
/// ```
/// ```objc
/// /// Objective-C
/// /// Disabling custom ID and Data migrations
/// [BatchSDK setDisabledMigrations: BatchMigrationCustomID | BatchMigrationCustomData];
/// ```
+ (void)setDisabledMigrations:(BatchMigration)migrations;

@end

/// BatchDeeplinkDelegate is the protocol to adopt when you want to set a deeplink delegate on the SDK.
///
/// See ``Batch/Batch/deeplinkDelegate`` for more info.
/// See ``Batch/BatchSDK/deeplinkDelegate`` for more info.
@protocol BatchDeeplinkDelegate <NSObject>

/// Method called when Batch needs to open a deeplink.
Expand Down
Loading

0 comments on commit 6ac4230

Please sign in to comment.