├── Sources ├── Cartfile.private ├── Cartfile.resolved ├── .gitignore ├── Batch │ ├── Modules │ │ ├── Debug │ │ │ ├── BADBGDebugViewController.h │ │ │ ├── BADBGLCListViewController.h │ │ │ ├── BADBGCustomDataViewController.h │ │ │ ├── BADBGIdentifiersViewController.h │ │ │ ├── BADBGLocalCampaignsViewController.h │ │ │ ├── BADBGModule.h │ │ │ ├── BADBGLCDetailsViewController.h │ │ │ ├── BADBGFindMyInstallationHelper.h │ │ │ ├── BADBGModule.m │ │ │ ├── BADBGNameValueListItem.h │ │ │ ├── BADBGCustomDataModels.h │ │ │ ├── BADBGCustomDataModels.m │ │ │ └── BADBGNameValueListItem.m │ │ ├── Core │ │ │ ├── BAInstallationID.h │ │ │ ├── BATUserActivity.h │ │ │ ├── BATInternalEvents.swift │ │ │ ├── BABundleInfo.h │ │ │ ├── BASessionManager.h │ │ │ └── BATUserActivity.m │ │ ├── Messaging │ │ │ ├── BAMSGCTA.m │ │ │ ├── CEP │ │ │ │ └── InApp │ │ │ │ │ ├── CTA │ │ │ │ │ ├── InAppCTAType.swift │ │ │ │ │ └── WebviewCTAComponent.swift │ │ │ │ │ ├── Objects │ │ │ │ │ ├── InAppFormat.swift │ │ │ │ │ ├── InAppComponent.swift │ │ │ │ │ ├── InAppCloseOptionDelay.swift │ │ │ │ │ ├── InAppAction.swift │ │ │ │ │ ├── InAppSpacer.swift │ │ │ │ │ ├── InAppCloseOptionCross.swift │ │ │ │ │ ├── InAppCloseOption.swift │ │ │ │ │ ├── InAppWebview.swift │ │ │ │ │ ├── InAppDivider.swift │ │ │ │ │ ├── InAppImage.swift │ │ │ │ │ ├── InAppColumns.swift │ │ │ │ │ └── InAppRootContainer.swift │ │ │ │ │ ├── Font │ │ │ │ │ └── InAppFontDecoration.swift │ │ │ │ │ ├── Types │ │ │ │ │ ├── InAppAspectRatio.swift │ │ │ │ │ ├── InAppVerticalAlignment.swift │ │ │ │ │ ├── InAppHorizontalAlignment.swift │ │ │ │ │ └── InAppWidthType.swift │ │ │ │ │ ├── Helpers │ │ │ │ │ ├── InAppRadiusIndexHelper.swift │ │ │ │ │ └── InAppEdgeIndexHelper.swift │ │ │ │ │ ├── Protocols │ │ │ │ │ ├── InAppTypedComponent.swift │ │ │ │ │ ├── InAppCTAComponent.swift │ │ │ │ │ ├── InAppErrorDelegate.swift │ │ │ │ │ ├── InAppAnalyticDelegate.swift │ │ │ │ │ ├── InAppClosureDelegate.swift │ │ │ │ │ ├── InAppFontDecorationStylizable.swift │ │ │ │ │ ├── InAppExpandableView.swift │ │ │ │ │ └── InAppExpandableComponent.swift │ │ │ │ │ ├── ViewControllers │ │ │ │ │ ├── Configurations │ │ │ │ │ │ └── InAppClose+Configuration.swift │ │ │ │ │ ├── InAppBannerViewController.swift │ │ │ │ │ └── InAppModalViewController.swift │ │ │ │ │ ├── Views │ │ │ │ │ └── InAppPercentedView.swift │ │ │ │ │ ├── Builder │ │ │ │ │ └── InAppUIEdgeInsetsBuilder.swift │ │ │ │ │ └── Models │ │ │ │ │ └── InAppCustomStyle.swift │ │ │ ├── Widgets │ │ │ │ ├── BAMSGPassthroughProtocol.h │ │ │ │ ├── BAMSGCountdownView.h │ │ │ │ ├── BAMSGButton.h │ │ │ │ ├── BAMSGPannableContainerView.h │ │ │ │ ├── BAMSGImageView.h │ │ │ │ ├── BAMSGBaseContainerView.h │ │ │ │ ├── BAMSGRemoteImageView.h │ │ │ │ ├── BAMSGLabel.h │ │ │ │ ├── BAMSGCloseButton.h │ │ │ │ ├── BAMSGStylableView.h │ │ │ │ └── BAMSGGradientView.h │ │ │ ├── BAMSGCTA.h │ │ │ ├── UI │ │ │ │ ├── BAMSGWindowHolder.h │ │ │ │ ├── BAMSGStackViewHorizontalItem.h │ │ │ │ ├── BAMSGVideoView.h │ │ │ │ ├── BAMSGBannerViewController.h │ │ │ │ ├── BAMSGImageViewController.h │ │ │ │ ├── BAMSGWebviewViewController.h │ │ │ │ ├── BAMSGModalViewController.h │ │ │ │ └── BAMSGStackViewItem.h │ │ │ ├── BAMSGOverlayWindow.h │ │ │ ├── CSS │ │ │ │ ├── BACSSBuiltinImportProvider.h │ │ │ │ ├── BACSSImportProvider.h │ │ │ │ ├── BACSSParser.h │ │ │ │ └── BACSSToken.h │ │ │ ├── BAMSGAction.m │ │ │ ├── BAMSGAction.h │ │ │ ├── Webview │ │ │ │ ├── BATWebviewUtils.h │ │ │ │ ├── BATWebviewUtils.m │ │ │ │ └── BATWebviewBridgeWKHandler.h │ │ │ ├── BAMSGPayloadParser.h │ │ │ ├── GIF │ │ │ │ └── BATGIFAnimator.h │ │ │ ├── BADelegatedUIAlertController.h │ │ │ ├── BAMSGImageDownloader.h │ │ │ └── BAMessagingAnalyticsDeduplicatingDelegate.h │ │ ├── Actions │ │ │ ├── BAUserDataBuiltinActions.h │ │ │ └── BAUserEventBuiltinActions.h │ │ ├── Inbox │ │ │ ├── BAInboxWebserviceResponse.m │ │ │ ├── BAInboxSQLiteHelper.h │ │ │ ├── BAInboxWebserviceClientType.h │ │ │ └── BAInboxWebserviceResponse.h │ │ ├── Local Campaigns │ │ │ ├── Triggers │ │ │ │ ├── BANextSessionTrigger.m │ │ │ │ ├── BALocalCampaignTriggerProtocol.h │ │ │ │ └── BANextSessionTrigger.h │ │ │ ├── BALocalCampaignsGlobalCappings.m │ │ │ ├── Signals │ │ │ │ ├── BANewSessionSignal.h │ │ │ │ ├── BANewSessionSignal.m │ │ │ │ ├── BAEventTrackedSignal.h │ │ │ │ ├── BALocalCampaignSignalProtocol.h │ │ │ │ ├── BAEventTrackedSignal.m │ │ │ │ └── BAPublicEventTrackedSignal.h │ │ │ ├── Persistence │ │ │ │ ├── BALocalCampaignsFilePersistence.h │ │ │ │ └── BALocalCampaignsPersisting.h │ │ │ ├── Tracker │ │ │ │ └── BALocalCampaignsTracker.h │ │ │ ├── Outputs │ │ │ │ ├── BALocalCampaignLandingOutput.h │ │ │ │ └── BALocalCampaignOutputProtocol.h │ │ │ ├── Models │ │ │ │ └── BALocalCampaignDayOfWeek.h │ │ │ ├── BALocalCampaignsGlobalCappings.h │ │ │ └── BALocalCampaign.m │ │ ├── User │ │ │ ├── BAUserCenter.h │ │ │ ├── BAUserDataEnums.h │ │ │ ├── BAUserDataOperation.h │ │ │ ├── BAUserDataOperation.m │ │ │ └── BAUserAttribute.h │ │ ├── Metrics │ │ │ ├── BACounter.h │ │ │ ├── BAMetricProtocol.h │ │ │ ├── BAObservation.h │ │ │ ├── BAMetricManager.h │ │ │ ├── BAMetricWebserviceClient.h │ │ │ └── BAMetricRegistry.h │ │ ├── Tracker │ │ │ ├── BAEventSQLiteHelper.h │ │ │ └── BATrackerSignpostHelper.h │ │ ├── Push │ │ │ ├── BAPushSystemHelper.h │ │ │ └── BAPushPayload.h │ │ ├── Profile │ │ │ └── BatchProfileError+Init.swift │ │ ├── Domain │ │ │ ├── BADomainService.swift │ │ │ └── BADomainManagerProtocol.swift │ │ ├── Opt Out │ │ │ ├── BAOptOutWebserviceClient.m │ │ │ ├── BAOptOutWebserviceClient.h │ │ │ └── BAOptOutEventTracker.h │ │ └── Event Dispatcher │ │ │ ├── BAPushEventPayload.h │ │ │ └── BAPushEventPayload.m │ ├── Kernel │ │ ├── Logger │ │ │ ├── BALoggerUnified.h │ │ │ └── BALoggerProtocol.h │ │ ├── Foundation │ │ │ ├── BAUptimeProvider.h │ │ │ ├── BASystemDateProvider.h │ │ │ ├── BASystemDateProvider.m │ │ │ ├── BADateProviderProtocol.h │ │ │ ├── BAMutableDateProvider.h │ │ │ ├── BASecureDateProvider.h │ │ │ ├── BAMutableDateProvider.m │ │ │ ├── BASecureDateProvider.m │ │ │ └── BAUptimeProvider.m │ │ ├── Helpers │ │ │ ├── BADateFormatting.h │ │ │ ├── BADictionaryHelper.h │ │ │ ├── BAStringUtils.h │ │ │ ├── BAThreading.h │ │ │ ├── BAWindowHelper.h │ │ │ ├── BANullHelper.h │ │ │ ├── BAHTTPHeaders.h │ │ │ ├── BAPartialApplicationDelegate.h │ │ │ ├── BARandom.h │ │ │ ├── BADateFormatting.m │ │ │ ├── BAStringUtils.m │ │ │ ├── BAOSHelper.h │ │ │ └── BARandom.m │ │ ├── Dependency Injection │ │ │ ├── Private │ │ │ │ ├── BAInjectionRegistrar.h │ │ │ │ ├── BAOverlayedInjectable-Private.h │ │ │ │ └── BAInjectableImplementations.h │ │ │ ├── BAOverlayedInjectable.h │ │ │ ├── BAOverlayedInjectable.m │ │ │ ├── BAInjectable.h │ │ │ └── BAInjectable.m │ │ ├── Crypto │ │ │ ├── BAAESB64Cryptor.h │ │ │ ├── BASHA.h │ │ │ └── BASHA.m │ │ ├── GZip │ │ │ └── BATGZIP.h │ │ ├── Concurrent │ │ │ ├── BATaskDebouncer.h │ │ │ └── BAPromise.h │ │ └── Parameters │ │ │ └── BAPropertiesCenter.h │ ├── Webservices │ │ ├── Core │ │ │ ├── BAConnectionContentType.h │ │ │ ├── BAURLSession.h │ │ │ ├── BAWebserviceClientExecutor.h │ │ │ ├── BAURLSession.m │ │ │ ├── BAURLSessionProtocol.h │ │ │ └── BAWebserviceClientExecutor.m │ │ ├── Query │ │ │ ├── BAQueryWebserviceIdentifiersProviding.h │ │ │ ├── BAStandardQueryWebserviceIdentifiersProvider.h │ │ │ ├── BAQueryWebserviceClientDelegate.h │ │ │ └── BAStandardQueryWebserviceIdentifiersProvider.m │ │ ├── Query Services Implementations │ │ │ ├── Query Models │ │ │ │ ├── BAWSQueryStart.h │ │ │ │ ├── BAWSQueryStart.m │ │ │ │ ├── BAWSQueryPushToken.h │ │ │ │ ├── BAWSQueryTracking.h │ │ │ │ ├── BAWSQueryAttributesCheck.h │ │ │ │ ├── BAWSQuery.m │ │ │ │ └── BAWSQueryLocalCampaigns.h │ │ │ ├── BAStartService.h │ │ │ ├── Response Models │ │ │ │ ├── BAWSResponseStart.m │ │ │ │ ├── BAWSResponseTracking.m │ │ │ │ ├── BAWSResponsePushToken.m │ │ │ │ ├── BAWSResponseTracking.h │ │ │ │ ├── BAWSResponsePushToken.h │ │ │ │ ├── BAWSResponseStart.h │ │ │ │ ├── BAWSResponseLocalCampaigns.h │ │ │ │ ├── BAWSResponseLocalCampaigns.m │ │ │ │ ├── BAWSResponse.m │ │ │ │ └── BAWSResponseAttributes.h │ │ │ ├── BAPushTokenService.h │ │ │ ├── BAEventTrackerService.h │ │ │ └── BALocalCampaignsService.h │ │ ├── Crypto │ │ │ ├── BAWebserviceCryptor.h │ │ │ ├── BAWebserviceStubCryptor.h │ │ │ ├── BAWebserviceAESGCMCryptor.h │ │ │ ├── BAWebserviceStubCryptor.m │ │ │ └── BAWebserviceAESGCMGzipCryptor.h │ │ ├── BAGETWebserviceClient.h │ │ ├── BAWebserviceURLBuilder.h │ │ └── BAResponseHelper.h │ ├── Supporting Files │ │ └── batch-Prefix.pch │ ├── BatchUserAttributePrivate.h │ ├── Versions.h │ ├── BANotificationCenter.m │ ├── BatchLogger.h │ ├── Info.plist │ ├── BANotificationCenter.h │ ├── BatchMessagingCloseReason.h │ ├── Batch.h │ ├── BatchDataCollectionConfig.m │ ├── BatchEventDispatcher.m │ └── BASecureDate.h ├── batchTests │ ├── Supporting Files │ │ └── batchTests-Bridging-Header.h │ ├── Webservices │ │ └── Query Services │ │ │ ├── queryTestHelpers.swift │ │ │ └── pushTokenServiceTests.swift │ ├── Mocks │ │ ├── DeeplinkDelegateStub.h │ │ ├── DeeplinkDelegateStub.m │ │ └── BatchUserDataEditorMock.swift │ ├── Modules │ │ ├── Messaging │ │ │ └── InApp │ │ │ │ ├── InAppWaitingTests.swift │ │ │ │ ├── InAppMessageBuilderOverriderTest.swift │ │ │ │ ├── InAppSpacerViewTests.swift │ │ │ │ └── InAppWidthTypeTests.swift │ │ ├── Profile │ │ │ ├── TestProfileEditor.swift │ │ │ ├── TestProfileCenter.swift │ │ │ └── profileCenterTests.swift │ │ ├── User │ │ │ └── userDataManagerTests.swift │ │ └── Inbox │ │ │ └── inboxFetcherTests.swift │ ├── OperatingSystemVersion+Equatable.swift │ ├── Kernel │ │ ├── Helpers │ │ │ └── swiftSwizzling.swift │ │ └── Logger │ │ │ └── loggerSetupTests.m │ ├── batchTestsBootstrap.m │ ├── InvocationRecorders.h │ ├── Info-test.plist │ └── DataUtils.swift ├── OCMock │ ├── OCMock-Prefix.pch │ ├── README.md │ ├── OCMock.modulemap │ ├── Info.plist │ ├── OCMArgAction.h │ ├── OCMExpectationRecorder.h │ ├── OCMock.h │ ├── OCMArgAction.m │ ├── OCMBoxedReturnValueProvider.h │ ├── OCMObjectReturnValueProvider.h │ ├── OCMPassByRefSetter.h │ ├── NSValue+OCMAdditions.h │ ├── OCMRealObjectForwarder.h │ ├── OCProtocolMockObject.h │ ├── OCMExceptionReturnValueProvider.h │ ├── OCMBlockArgCaller.h │ ├── OCMFunctions.h │ ├── NSObject+OCMAdditions.h │ ├── OCMNotificationPoster.h │ ├── OCPartialMockObject.h │ ├── OCMBlockCaller.h │ ├── OCMInvocationExpectation.h │ ├── OCMNonRetainingObjectReturnValueProvider.h │ ├── NSNotificationCenter+OCMAdditions.h │ ├── OCMVerifier.h │ ├── OCMIndirectReturnValueProvider.h │ └── OCMInvocationStub.h ├── Batch.xcodeproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── swiftpm │ │ └── Package.resolved ├── bridgy.config.json └── sdk.xctestplan ├── Tools ├── Sources │ └── Tools │ │ └── .gitkeep ├── Bridgy │ ├── .gitignore │ ├── Sources │ │ └── Bridgy │ │ │ ├── main.swift │ │ │ └── Config.swift │ └── Package.swift ├── Scripts │ ├── generate_private_umbrella_header.sh │ ├── make_doc.sh │ └── strip_public_swift_framework.sh ├── XcodeTemplates │ └── Batch Unit Test Case Class.xctemplate │ │ ├── TemplateIcon-1016.png │ │ ├── TemplateIcon-1016@2x.png │ │ └── XCTestCaseSwift │ │ └── ___FILEBASENAME___.swift ├── .swiftpm │ └── xcode │ │ └── package.xcworkspace │ │ └── contents.xcworkspacedata └── Dockerfile.format ├── .gitignore ├── .github ├── pull_request_template.md └── ISSUE_TEMPLATE │ └── config.yml ├── .clang-format ├── BUILDING.md ├── LICENSE └── Package.swift /Sources/Cartfile.private: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Sources/Cartfile.resolved: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Tools/Sources/Tools/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Sources/.gitignore: -------------------------------------------------------------------------------- 1 | Carthage/Checkouts 2 | Carthage/Build 3 | -------------------------------------------------------------------------------- /Tools/Bridgy/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.build 3 | /Packages 4 | /*.xcodeproj 5 | xcuserdata/ 6 | Package.resolved 7 | .swiftpm 8 | -------------------------------------------------------------------------------- /Tools/Scripts/generate_private_umbrella_header.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | swift run -c release --package-path ../Tools/Bridgy Bridgy ./bridgy.config.json 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Sources/build 3 | Sources/universal/ 4 | Sources/universalBridge/ 5 | Sources/api-doc/ 6 | output 7 | .svn 8 | *.xcuserdatad 9 | .idea/ -------------------------------------------------------------------------------- /Sources/Batch/Modules/Debug/BADBGDebugViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface BADBGDebugViewController : UITableViewController 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Debug/BADBGLCListViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface BADBGLCListViewController : UITableViewController 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Debug/BADBGCustomDataViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface BADBGCustomDataViewController : UITableViewController 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Debug/BADBGIdentifiersViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface BADBGIdentifiersViewController : UITableViewController 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /Tools/Bridgy/Sources/Bridgy/main.swift: -------------------------------------------------------------------------------- 1 | import Darwin 2 | 3 | do { 4 | try CommandLine.run() 5 | } catch { 6 | print("Failed: \(error)") 7 | exit(EXIT_FAILURE) 8 | } -------------------------------------------------------------------------------- /Sources/Batch/Modules/Debug/BADBGLocalCampaignsViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface BADBGLocalCampaignsViewController : UITableViewController 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Debug/BADBGModule.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface BADBGModule : NSObject 4 | 5 | + (UIViewController *)debugViewController; 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Logger/BALoggerUnified.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface BALoggerUnified : NSObject 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /Sources/batchTests/Supporting Files/batchTests-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | #import "OCMock.h" 5 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMock-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'OCMock' target in the 'OCMock' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /Sources/OCMock/README.md: -------------------------------------------------------------------------------- 1 | This folder contains a vendored OCMock : https://github.com/erikdoe/ocmock due to SPM limitations with "unsafe" flags 2 | OCMock.modulemap comes from https://github.com/firebase/ocmock 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Batch Support 4 | url: https://batch.com/en/support/ 5 | about: Reach our support team via email or Live-Chat. 6 | -------------------------------------------------------------------------------- /Tools/XcodeTemplates/Batch Unit Test Case Class.xctemplate/TemplateIcon-1016.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BatchLabs/Batch-iOS-SDK/HEAD/Tools/XcodeTemplates/Batch Unit Test Case Class.xctemplate/TemplateIcon-1016.png -------------------------------------------------------------------------------- /Sources/Batch/Modules/Core/BAInstallationID.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface BAInstallationID : NSObject 4 | 5 | + (nullable NSString *)installationID; 6 | 7 | + (void)delete; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /Tools/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Tools/XcodeTemplates/Batch Unit Test Case Class.xctemplate/TemplateIcon-1016@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BatchLabs/Batch-iOS-SDK/HEAD/Tools/XcodeTemplates/Batch Unit Test Case Class.xctemplate/TemplateIcon-1016@2x.png -------------------------------------------------------------------------------- /Sources/Batch.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/BAMSGCTA.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGCTA.m 3 | // ViewTest 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @implementation BAMSGCTA 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Actions/BAUserDataBuiltinActions.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import 4 | 5 | @interface BAUserDataBuiltinActions : NSObject 6 | 7 | + (BatchUserAction *)tagEditAction; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: Chromium 3 | IndentWidth: 4 4 | ColumnLimit: 120 5 | AlignTrailingComments: true 6 | ObjCSpaceAfterProperty: true 7 | ObjCSpaceBeforeProtocolList: true 8 | PointerBindsToType: false 9 | SpacesBeforeTrailingComments: 1 10 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Actions/BAUserEventBuiltinActions.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import 4 | 5 | @interface BAUserEventBuiltinActions : NSObject 6 | 7 | + (BatchUserAction *)trackEventAction; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/CTA/InAppCTAType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Types of the CTA 8 | enum InAppCTAType: String { 9 | case image, button, webview 10 | } 11 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Debug/BADBGLCDetailsViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import 4 | 5 | @interface BADBGLCDetailsViewController : UITableViewController 6 | 7 | - (void)setCampaign:(BALocalCampaign *)campaign; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/Widgets/BAMSGPassthroughProtocol.h: -------------------------------------------------------------------------------- 1 | @protocol BAMSGPasstroughProtocol 2 | 3 | /** 4 | Hint for a custom UIWindow that touches made on this container view should pass through to the underlying windows 5 | */ 6 | @property BOOL touchPassthrough; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Core/BAConnectionContentType.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAConnectionContentType.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | typedef NS_ENUM(NSUInteger, BAConnectionContentType) { 9 | BAConnectionContentTypeJSON, 10 | }; 11 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Inbox/BAInboxWebserviceResponse.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAInboxWebserviceResponse.m 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @implementation BAInboxWebserviceResponse 11 | @end 12 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Objects/InAppFormat.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Represents an in-app format 8 | public enum InAppFormat: String, Codable { 9 | case modal, fullscreen, webview 10 | } 11 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Font/InAppFontDecoration.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Font decoration 8 | public enum InAppFontDecoration: String, Codable { 9 | case bold, italic, underline, stroke 10 | } 11 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Local Campaigns/Triggers/BANextSessionTrigger.m: -------------------------------------------------------------------------------- 1 | // 2 | // BANextSessionTrigger.m 3 | // Batch 4 | // 5 | // Copyright © 2017 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @implementation BANextSessionTrigger 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Foundation/BAUptimeProvider.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAUptimeProvider.h 3 | // Batch 4 | // 5 | // Copyright © 2017 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface BAUptimeProvider : NSObject 11 | 12 | + (NSTimeInterval)uptime; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Helpers/BADateFormatting.h: -------------------------------------------------------------------------------- 1 | // 2 | // BADateFormatting.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface BADateFormatting : NSObject 11 | 12 | + (NSDateFormatter *)dateFormatter; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Debug/BADBGFindMyInstallationHelper.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface BADBGFindMyInstallationHelper : NSObject 4 | 5 | @property (class) BOOL enablesFindMyInstallation; 6 | 7 | - (nonnull instancetype)initWithPasteboard:(nonnull UIPasteboard *)pasteboard; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Types/InAppAspectRatio.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Define the aspect ration logic than ``InAppImage`` could use 8 | public enum InAppAspectRatio: String, Codable { 9 | case fit 10 | case fill 11 | } 12 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Local Campaigns/Triggers/BALocalCampaignTriggerProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // BALocalCampaignTriggerProtocol.h 3 | // Batch 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @protocol BALocalCampaignTriggerProtocol 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Helpers/InAppRadiusIndexHelper.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Helper to centralize index logic 8 | enum InAppRadiusIndexHelper: Int { 9 | case topLeft = 0 10 | case topRight, bottomRight, bottomLeft 11 | } 12 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/BAMSGCTA.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGCTA.h 3 | // ViewTest 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @interface BAMSGCTA : BAMSGAction 12 | 13 | @property (nonnull) NSString *label; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/UI/BAMSGWindowHolder.h: -------------------------------------------------------------------------------- 1 | /** 2 | Protocol defining an object that can weakly hold a UIWindow 3 | */ 4 | @protocol BAMSGWindowHolder 5 | 6 | @required 7 | 8 | @property (nullable, weak) UIWindow *presentingWindow; 9 | @property (nullable, weak) UIWindow *overlayedWindow; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /BUILDING.md: -------------------------------------------------------------------------------- 1 | # Building Batch SDK 2 | 3 | ## Requirements 4 | 5 | - Latest Xcode 6 | 7 | 8 | ## Steps 9 | 10 | - Open `batch.xcodeproj`. Dependencies are added using Swift Package Manager, Xcode will download them automatically 11 | - Archive the `BatchXCFramework` target 12 | - `Batch.xcframework` will be available in `Sources/universal` -------------------------------------------------------------------------------- /Sources/batchTests/Webservices/Query Services/queryTestHelpers.swift: -------------------------------------------------------------------------------- 1 | // 2 | // queryTestHelpers.swift 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | import Foundation 9 | 10 | public func makeBasicQueryResponseDictionary() -> [AnyHashable: Any] { 11 | return ["id": UUID().uuidString] 12 | } 13 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Debug/BADBGModule.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import 4 | 5 | @implementation BADBGModule 6 | 7 | + (UIViewController *)debugViewController { 8 | return [[UINavigationController alloc] initWithRootViewController:[BADBGDebugViewController new]]; 9 | } 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Objects/InAppComponent.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Represents available in-app components 8 | public enum InAppComponent: String, Codable, CaseIterable { 9 | case button, columns, divider, image, text, spacer, webview 10 | } 11 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Foundation/BASystemDateProvider.h: -------------------------------------------------------------------------------- 1 | // 2 | // BASystemDateProvider.h 3 | // Batch 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @interface BASystemDateProvider : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Local Campaigns/BALocalCampaignsGlobalCappings.m: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | #import "BALocalCampaignsGlobalCappings.h" 8 | 9 | @implementation BALocalCampaignsGlobalCappings 10 | 11 | @end 12 | 13 | @implementation BALocalCampaignsTimeBasedCapping 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/User/BAUserCenter.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAUserCenter.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2015 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface BAUserCenter : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Tools/Scripts/make_doc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rm -rf api-doc/ 3 | jazzy --objc \ 4 | --clean \ 5 | --author Batch \ 6 | --author_url https://batch.com \ 7 | --module Batch \ 8 | --hide-documentation-coverage \ 9 | --umbrella-header Batch/Batch.h \ 10 | --framework-root .\ 11 | --sdk iphonesimulator \ 12 | --output api-doc/ 13 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Foundation/BASystemDateProvider.m: -------------------------------------------------------------------------------- 1 | // 2 | // BASystemDateProvider.m 3 | // Batch 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @implementation BASystemDateProvider 11 | 12 | - (NSDate *)currentDate { 13 | return [NSDate date]; 14 | } 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/BAMSGOverlayWindow.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | #import 5 | 6 | @interface BAMSGOverlayWindow : UIWindow 7 | 8 | @property NSTimeInterval visibilityAnimationDuration; 9 | 10 | - (void)presentAnimated; 11 | 12 | - (BAPromise *)dismissAnimated; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Protocols/InAppTypedComponent.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Define a type to help the deserialization of ``AnyCodable`` by ``AnyCodableBuilder`` 8 | public protocol InAppTypedComponent: Codable { 9 | var type: InAppComponent { get } 10 | } 11 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Types/InAppVerticalAlignment.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Define the vertical alignment logic than a component could use 8 | public enum InAppVerticalAlignment: String, Codable { 9 | case top 10 | case center 11 | case bottom 12 | } 13 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Core/BATUserActivity.h: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | NS_ASSUME_NONNULL_BEGIN 10 | 11 | @interface BATUserActivity : NSUserActivity 12 | 13 | @property (assign) BOOL hasUniversalLink; 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Debug/BADBGNameValueListItem.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface BADBGNameValueCell : UITableViewCell 4 | @end 5 | 6 | @interface BADBGNameValueListItem : NSObject 7 | 8 | @property NSString *name; 9 | @property NSString *value; 10 | 11 | + (instancetype)itemWithName:(NSString *)name value:(NSString *)value; 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Protocols/InAppCTAComponent.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Generalize CTA component 8 | protocol InAppCTAComponent { 9 | var analyticsIdentifier: String { get } 10 | var action: BAMSGAction? { get } 11 | var type: InAppCTAType { get } 12 | } 13 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Dependency Injection/Private/BAInjectionRegistrar.h: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | NS_ASSUME_NONNULL_BEGIN 10 | 11 | @interface BAInjectionRegistrar : NSObject 12 | 13 | + (void)registerInjectables; 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Inbox/BAInboxSQLiteHelper.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAInboxSQLiteHelper.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | 12 | @interface BAInboxSQLiteHelper : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Protocols/InAppErrorDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Generalize error interactions 8 | protocol InAppErrorDelegate { 9 | typealias Closure = (_ error: any Error, _ component: InAppComponent) -> Void 10 | 11 | var onError: Closure { get } 12 | } 13 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CSS/BACSSBuiltinImportProvider.h: -------------------------------------------------------------------------------- 1 | // 2 | // BACSSBuiltinImportProvider.h 3 | // Batch 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | @interface BACSSBuiltinImportProvider : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Sources/Batch/Supporting Files/batch-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #ifdef __OBJC__ 8 | #import 9 | #import 10 | 11 | #import "Defined.h" 12 | #import 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/CTA/WebviewCTAComponent.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | // MARK: - WebviewCTAComponent 8 | 9 | struct WebviewCTAComponent: InAppCTAComponent { 10 | let analyticsIdentifier: String 11 | let action: BAMSGAction? 12 | let type: InAppCTAType = .webview 13 | } 14 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Protocols/InAppAnalyticDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Generalize analytic interactions 8 | protocol InAppAnalyticDelegate { 9 | typealias Trigger = (_ source: InAppAnalyticWrapper.Kind) -> Void 10 | 11 | var analyticTrigger: Trigger { get } 12 | } 13 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Metrics/BACounter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | #import 7 | #import 8 | 9 | @interface BACounter : BAMetric 10 | 11 | /// Increment the counter value 12 | - (void)increment; 13 | 14 | /// Reset the counter value 15 | - (void)reset; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Core/BATInternalEvents.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | import Foundation 8 | 9 | public enum BATInternalEvent: String { 10 | case profileIdentify = "_PROFILE_IDENTIFY" 11 | case profileDataChanged = "_PROFILE_DATA_CHANGED" 12 | case nativeDataChanged = "_NATIVE_DATA_CHANGED" 13 | } 14 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Local Campaigns/Signals/BANewSessionSignal.h: -------------------------------------------------------------------------------- 1 | // 2 | // BANewSessionSignal.h 3 | // Batch 4 | // 5 | // Copyright © 2017 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | @interface BANewSessionSignal : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Local Campaigns/Triggers/BANextSessionTrigger.h: -------------------------------------------------------------------------------- 1 | // 2 | // BANextSessionTrigger.h 3 | // Batch 4 | // 5 | // Copyright © 2017 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @interface BANextSessionTrigger : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Protocols/InAppClosureDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Generalize closure interactions 8 | protocol InAppClosureDelegate { 9 | typealias Closure = (_ item: InAppCTAComponent?, _ error: Error?) -> Void 10 | 11 | var onClosureTap: Closure { get } 12 | } 13 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CSS/BACSSImportProvider.h: -------------------------------------------------------------------------------- 1 | // 2 | // BACSSImportProvider.h 3 | // Batch 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @protocol BACSSImportProvider 11 | 12 | @required 13 | - (NSString *_Nullable)contentForImportNamed:(NSString *_Nonnull)importName; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Sources/bridgy.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "output_directory": "Batch/", 3 | "base_search_path": ".", 4 | "headers": { 5 | "PrivateUmbrellaHeader.h": { 6 | "path": "Batch", 7 | "recursive": true, 8 | "ignoredNames": "(^(?!.*Private)Batch.*\\.h$)|(^Versions.h$)", 9 | "frameworkName": "Batch" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Types/InAppHorizontalAlignment.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | import UIKit 8 | 9 | /// Define the horizontal alignment logic than a component could use 10 | public enum InAppHorizontalAlignment: String, Codable { 11 | case left 12 | case center 13 | case right 14 | } 15 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/Widgets/BAMSGCountdownView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import 4 | 5 | @interface BAMSGCountdownView : UIView 6 | 7 | /** 8 | Set the progression percentage, between 0 and 1 9 | */ 10 | - (void)setPercentage:(float)percentage; 11 | 12 | - (void)setColor:(nonnull UIColor *)color; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Sources/batchTests/Mocks/DeeplinkDelegateStub.h: -------------------------------------------------------------------------------- 1 | // 2 | // DeeplinkDelegateStub.h 3 | // BatchTests 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @interface DeeplinkDelegateStub : NSObject 12 | 13 | @property (assign) BOOL hasOpenBeenCalled; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/BAMSGAction.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGAction.m 3 | // Batch 4 | // 5 | // Copyright © 2017 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @implementation BAMSGAction 11 | 12 | - (BOOL)isDismissAction { 13 | return self.actionIdentifier == nil || [@"batch.dismiss" isEqualToString:self.actionIdentifier]; 14 | } 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Inbox/BAInboxWebserviceClientType.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAInboxWebserviceClientType.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | typedef NS_ENUM(NSUInteger, BAInboxWebserviceClientType) { 11 | BAInboxWebserviceClientTypeInstallation = 0, 12 | BAInboxWebserviceClientTypeUserIdentifier = 1, 13 | }; 14 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Tracker/BAEventSQLiteHelper.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAEventSQLiteHelper.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | @interface BAEventSQLiteHelper : NSObject 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query/BAQueryWebserviceIdentifiersProviding.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2019 Batch.com. All rights reserved. 3 | // 4 | 5 | #import 6 | 7 | /** 8 | * Provides common identifiers to add in the query WS 9 | */ 10 | @protocol BAQueryWebserviceIdentifiersProviding 11 | 12 | - (NSDictionary *)identifiers; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Local Campaigns/Persistence/BALocalCampaignsFilePersistence.h: -------------------------------------------------------------------------------- 1 | // 2 | // BALocalCampaignsFilePersistence.h 3 | // Batch 4 | // 5 | // Copyright © 2017 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @interface BALocalCampaignsFilePersistence : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Metrics/BAMetricProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | #import 7 | 8 | @protocol BAMetricProtocol 9 | 10 | @required 11 | /// Initialize a new metric child 12 | - (id)newChild:(NSMutableArray *)labels; 13 | 14 | @required 15 | /// Reset metric values 16 | - (void)reset; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Protocols/InAppFontDecorationStylizable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Generalize decoration style for ``InAppButtonView.Configuration.FontStyle`` and ``InAppLabelView.Configuration.FontStyle`` 8 | protocol InAppFontDecorationStylizable { 9 | var fontDecoration: [InAppFontDecoration]? { get } 10 | } 11 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/UI/BAMSGStackViewHorizontalItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGStackViewHorizontalItem.h 3 | // Batch 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface BAMSGStackViewHorizontalItem : BAMSGStackViewItem 11 | 12 | @end 13 | 14 | @interface BAMSGStackViewHorizontalSeparatorItem : BAMSGStackViewHorizontalItem 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Core/BAURLSession.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAURLSession.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface BAURLSession : NSObject 15 | 16 | + (id)sharedSession; 17 | 18 | @end 19 | 20 | NS_ASSUME_NONNULL_END 21 | -------------------------------------------------------------------------------- /Sources/Batch/BatchUserAttributePrivate.h: -------------------------------------------------------------------------------- 1 | // 2 | // BatchUserAttributePrivate.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | // Expose private constructors 9 | // This header is private and should NEVER be distributed within the framework 10 | 11 | @interface BatchUserAttribute () 12 | - (nullable instancetype)initWithValue:(nonnull id)value type:(BatchUserAttributeType)type; 13 | @end 14 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/BAMSGAction.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGAction.h 3 | // Batch 4 | // 5 | // Copyright © 2017 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface BAMSGAction : NSObject 11 | 12 | @property (nullable) NSString *actionIdentifier; 13 | @property (nonnull) NSDictionary *actionArguments; 14 | 15 | - (BOOL)isDismissAction; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Helpers/BADictionaryHelper.h: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | @interface BADictionaryHelper : NSObject 10 | 11 | + (BOOL)dictionary:(NSDictionary *)actual containsValuesFromDictionary:(NSDictionary *)expected; 12 | 13 | + (BOOL)array:(NSArray *)actual containsValuesFromArray:(NSArray *)expected; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Push/BAPushSystemHelper.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAPushSystemHelper.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2016 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | 13 | // UNUserNotification based implementation 14 | @interface BAPushSystemHelper : NSObject 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Local Campaigns/Tracker/BALocalCampaignsTracker.h: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | #import 8 | #import 9 | 10 | @interface BALocalCampaignsTracker : BALocalCampaignsSQLTracker 11 | 12 | @property (readonly) NSUInteger sessionViewsCount; 13 | 14 | - (void)resetSessionViewsCount; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Local Campaigns/Outputs/BALocalCampaignLandingOutput.h: -------------------------------------------------------------------------------- 1 | // 2 | // BALocalCampaignLandingOutput.h 3 | // Batch 4 | // 5 | // Copyright © 2017 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | #import 12 | 13 | @interface BALocalCampaignLandingOutput : NSObject 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Sources/Batch/Versions.h: -------------------------------------------------------------------------------- 1 | /* 2 | Versions.h 3 | Batch 4 | 5 | Copyright © Batch.com. All rights reserved. 6 | 7 | 8 | This header only contains the SDK versions 9 | It is included by defined.h the Info.plist preprocessor so that we can reference this in it 10 | 11 | Comments should not use the // form, as the plist preprocessor will include them 12 | */ 13 | 14 | #define BASDKVersion 3.2.0 15 | #define BAAPILevel 320 16 | #define BAMessagingAPILevel 32 17 | -------------------------------------------------------------------------------- /Sources/Batch.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "object": { 3 | "pins": [ 4 | { 5 | "package": "InstantMock", 6 | "repositoryURL": "https://github.com/pirishd/InstantMock", 7 | "state": { 8 | "branch": null, 9 | "revision": "5172aedc823dcefd9a3e2d0aedf9b51b000dabb2", 10 | "version": "2.5.5" 11 | } 12 | } 13 | ] 14 | }, 15 | "version": 1 16 | } 17 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Debug/BADBGCustomDataModels.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface BADBGCustomDataTagCollection : NSObject 4 | 5 | @property NSString *collectionName; 6 | @property NSArray *tags; 7 | 8 | @end 9 | 10 | @interface BADBGCustomDataAttribute : NSObject 11 | 12 | @property NSString *name; 13 | @property NSString *value; 14 | 15 | + (instancetype)attributeWithName:(NSString *)name value:(NSString *)value; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Debug/BADBGCustomDataModels.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @implementation BADBGCustomDataTagCollection 4 | 5 | @end 6 | 7 | @implementation BADBGCustomDataAttribute 8 | 9 | + (instancetype)attributeWithName:(NSString *)name value:(NSString *)value { 10 | BADBGCustomDataAttribute *item = [[BADBGCustomDataAttribute alloc] init]; 11 | item.name = name; 12 | item.value = value; 13 | return item; 14 | } 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/UI/BAMSGVideoView.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGVideoView.h 3 | // Batch 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | #import 12 | 13 | @interface BAMSGVideoView : UIView 14 | 15 | - (instancetype)initWithURL:(NSURL *)url; 16 | 17 | - (void)viewDidAppear; 18 | 19 | - (void)viewDidDisappear; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Foundation/BADateProviderProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // BADateProviderProtocol.h 3 | // Batch 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | /** 13 | Simple protocol for a date provider, allowing it to be mocked for tests 14 | */ 15 | @protocol BADateProviderProtocol 16 | 17 | - (NSDate *)currentDate; 18 | 19 | @end 20 | 21 | NS_ASSUME_NONNULL_END 22 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Profile/BatchProfileError+Init.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | import Foundation 8 | 9 | /// Convinence initializer for the generated BatchProfileError that makes it less verbose 10 | /// to add a description 11 | extension BatchProfileError { 12 | init(code: BatchProfileError.Code, reason: String) { 13 | self.init(code, userInfo: [NSLocalizedDescriptionKey: reason]) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/User/BAUserDataEnums.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAUserDataEnums.h 3 | // Batch 4 | // 5 | // Copyright © 2015 Batch. All rights reserved. 6 | // 7 | 8 | typedef NS_ENUM(int, BAUserAttributeType) { 9 | BAUserAttributeTypeDeleted = 0, 10 | BAUserAttributeTypeString = 1, 11 | BAUserAttributeTypeLongLong = 2, 12 | BAUserAttributeTypeDouble = 3, 13 | BAUserAttributeTypeBool = 4, 14 | BAUserAttributeTypeDate = 5, 15 | BAUserAttributeTypeURL = 6 16 | }; 17 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMock.modulemap: -------------------------------------------------------------------------------- 1 | framework module OCMock { 2 | header "OCMock.h" 3 | header "OCMockObject.h" 4 | header "OCMArg.h" 5 | header "OCMConstraint.h" 6 | header "OCMLocation.h" 7 | header "OCMMacroState.h" 8 | header "OCMRecorder.h" 9 | header "OCMStubRecorder.h" 10 | header "NSNotificationCenter+OCMAdditions.h" 11 | header "OCMFunctions.h" 12 | header "OCMVerifier.h" 13 | header "OCMQuantifier.h" 14 | header "OCMockMacros.h" 15 | export * 16 | } 17 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Metrics/BAObservation.h: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | #import 8 | #import 9 | @interface BAObservation : BAMetric 10 | 11 | /// Increment the observation value 12 | - (void)startTimer; 13 | 14 | /// Observe the duration since startTimer has been called 15 | - (void)observeDuration; 16 | 17 | /// Reset the observation value 18 | - (void)reset; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Sources/batchTests/Modules/Messaging/InApp/InAppWaitingTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | struct InAppWaitingForTests { 8 | static func wait(for timeInterval: TimeInterval = 2) async { 9 | await withCheckedContinuation { continuation in 10 | DispatchQueue.main.asyncAfter(deadline: .now() + timeInterval) { 11 | continuation.resume() 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Dependency Injection/Private/BAOverlayedInjectable-Private.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAOverlayedInjectable-Private.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | #import 8 | 9 | @interface BAOverlayedInjectable () 10 | 11 | - (nonnull instancetype)initWithCallback:(nonnull BAOverlayedInjectableCallback)callback; 12 | 13 | - (nullable id)resolveWithOriginalInstance:(nullable id)originalInstance; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Foundation/BAMutableDateProvider.h: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | #import 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface BAMutableDateProvider : NSObject 13 | 14 | - (instancetype)initWithTimestamp:(double)timestamp; 15 | 16 | - (void)setTime:(double)timestamp; 17 | 18 | @end 19 | 20 | NS_ASSUME_NONNULL_END 21 | -------------------------------------------------------------------------------- /Sources/batchTests/OperatingSystemVersion+Equatable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BatchTests 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | import Foundation 8 | 9 | extension OperatingSystemVersion: Equatable { 10 | public static func == (lhs: OperatingSystemVersion, rhs: OperatingSystemVersion) -> Bool { 11 | return lhs.majorVersion == rhs.majorVersion && lhs.minorVersion == rhs.minorVersion 12 | && lhs.patchVersion == rhs.patchVersion 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Crypto/BAAESB64Cryptor.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAAESB64Cryptor.h 3 | // Core 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2012 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | 13 | /*! 14 | @class BAAESB64Cryptor 15 | @abstract AES+B64 cryptor data. 16 | */ 17 | @interface BAAESB64Cryptor : NSObject 18 | 19 | - (instancetype)init NS_UNAVAILABLE; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Local Campaigns/Signals/BANewSessionSignal.m: -------------------------------------------------------------------------------- 1 | // 2 | // BANewSessionSignal.m 3 | // Batch 4 | // 5 | // Copyright © 2017 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | @implementation BANewSessionSignal 13 | 14 | - (BOOL)doesSatisfyTrigger:(nullable id)trigger { 15 | return [trigger isKindOfClass:[BANextSessionTrigger class]]; 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/Webview/BATWebviewUtils.h: -------------------------------------------------------------------------------- 1 | // 2 | // BATWebviewUtils.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface BATWebviewUtils : NSObject 13 | 14 | // Returns the value of the "batchAnalyticsID" get parameter in an URL if available 15 | + (nullable NSString *)analyticsIdForURL:(nonnull NSString *)url; 16 | 17 | @end 18 | 19 | NS_ASSUME_NONNULL_END 20 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Local Campaigns/Signals/BAEventTrackedSignal.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAEventTrackedSignal.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | @interface BAEventTrackedSignal : NSObject 13 | 14 | @property (nonnull, copy) NSString *name; 15 | 16 | - (nonnull instancetype)initWithName:(nonnull NSString *)name; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/User/BAUserDataOperation.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAUserDataOperation.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2015 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Inspired by NSBlockOperation, but supports returning a value 12 | @interface BAUserDataOperation : NSObject { 13 | BOOL (^_operationBlock)(void); 14 | } 15 | 16 | - (instancetype)initWithBlock:(BOOL (^)(void))block; 17 | 18 | - (BOOL)run; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Helpers/BAStringUtils.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAStringUtils.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2016 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BAStringUtils : NSObject 12 | 13 | /*! 14 | @method hexStringValueForData: 15 | @abstract Generate the hexadeciaml value of the data. 16 | @return Hexadecimal string. 17 | */ 18 | + (nonnull NSString *)hexStringValueForData:(nonnull NSData *)data; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Domain/BADomainService.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | @objc 8 | public enum BADomainService: Int { 9 | case web, metric 10 | 11 | func url(domain: String) -> String { 12 | let fullDomain = 13 | switch self { 14 | case .web: "ws.\(domain)" 15 | case .metric: "wsmetrics.\(domain)/api-sdk" 16 | } 17 | 18 | return "https://\(fullDomain)" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Objects/InAppCloseOptionDelay.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Represents an in-app auto close delay mechanism 8 | public struct InAppCloseOptionDelay: Codable { 9 | // MARK: - 10 | 11 | let delay: Int 12 | let color: [String]? 13 | 14 | // MARK: - 15 | 16 | public init(delay: Int, color: [String]?) { 17 | self.delay = delay 18 | self.color = color 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Core/BAWebserviceClientExecutor.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAWebserviceClientExecutor.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface BAWebserviceClientExecutor : NSObject 15 | 16 | + (instancetype)sharedInstance; 17 | 18 | - (void)addClient:(BAWebserviceClient *)client; 19 | 20 | @end 21 | 22 | NS_ASSUME_NONNULL_END 23 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Dependency Injection/BAOverlayedInjectable.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAOverlayedInjectable.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | typedef _Nullable id (^BAOverlayedInjectableCallback)(_Nullable id originalInstance); 11 | 12 | @interface BAOverlayedInjectable : NSObject 13 | 14 | /** 15 | Use BAInjection to get an instance of this object 16 | */ 17 | - (nonnull instancetype)init NS_UNAVAILABLE; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Objects/InAppAction.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Represents an in-app action 8 | public struct InAppAction: Codable { 9 | // MARK: - 10 | 11 | let action: String 12 | let params: [String: AnyCodable]? 13 | 14 | // MARK: - 15 | 16 | public init(action: String, params: [String: AnyCodable]? = nil) { 17 | self.action = action 18 | self.params = params 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Objects/InAppSpacer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Represents an in-app spacer 8 | public struct InAppSpacer: Codable, InAppTypedComponent, InAppExpandableComponent { 9 | // MARK: - 10 | 11 | public let type: InAppComponent 12 | let height: String 13 | 14 | // MARK: - 15 | 16 | public init(height: String) { 17 | self.type = .spacer 18 | self.height = height 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Helpers/BAThreading.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAThreading.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2016 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BAThreading : NSObject 12 | 13 | + (void)performBlockOnMainThread:(dispatch_block_t)block; 14 | 15 | + (void)performBlockOnMainThread:(dispatch_block_t)block secondDelay:(NSTimeInterval)delay; 16 | 17 | + (void)performBlockOnMainThreadAsync:(dispatch_block_t)block; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Logger/BALoggerProtocol.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | @protocol BALoggerProtocol 6 | 7 | - (void)logMessage:(NSString *)message 8 | subsystem:(NSString *)subsystem 9 | internal:(BOOL)internal 10 | level:(os_log_type_t)level; 11 | 12 | @end 13 | 14 | @protocol BALoggerDelegateSource 15 | 16 | @property (nonatomic, readonly) id loggerDelegate; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/ViewControllers/Configurations/InAppClose+Configuration.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Configuration for close logics and behaviors 8 | extension InAppViewController.Configuration.CloseConfiguration { 9 | struct Cross { 10 | let color: UIColor 11 | let backgroundColor: UIColor? 12 | } 13 | 14 | struct Delay { 15 | let value: Int 16 | let color: UIColor? 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Sources/batchTests/Modules/Profile/TestProfileEditor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BatchTests 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | import Batch 8 | import Foundation 9 | 10 | @testable import Batch.Batch_Private 11 | 12 | /// A test BATProfileEditor that has a controllable canSetEmail 13 | class TestProfileEditor: BATProfileEditor { 14 | public var test_isProfileIdentified = true 15 | 16 | override func isProfileIdentified() -> Bool { 17 | return test_isProfileIdentified 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/GZip/BATGZIP.h: -------------------------------------------------------------------------------- 1 | // 2 | // BATGZIP.h 3 | // Batch 4 | // 5 | // Copyright © 2020 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface BATGZIP : NSObject 11 | 12 | // Gzip data. If the data is already Gzipped, this returns the original data 13 | + (nullable NSData *)dataByGzipping:(nullable NSData *)data; 14 | 15 | // Gunzip data. If the data isn't Gzipped, this returns the original data 16 | + (nullable NSData *)dataByGunzipping:(nullable NSData *)data; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Inbox/BAInboxWebserviceResponse.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAInboxWebserviceResponse.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | @class BAInboxNotificationContent; 9 | 10 | @interface BAInboxWebserviceResponse : NSObject 11 | 12 | @property (nonatomic, assign) BOOL hasMore; 13 | @property (nonatomic, assign) BOOL didTimeout; 14 | @property (nonatomic, nullable) NSString *cursor; 15 | @property (nonatomic, nonnull) NSArray *notifications; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Local Campaigns/Persistence/BALocalCampaignsPersisting.h: -------------------------------------------------------------------------------- 1 | // 2 | // BALocalCampaignsPersisting.h 3 | // Batch 4 | // 5 | // Copyright © 2017 Batch. All rights reserved. 6 | // 7 | 8 | NS_ASSUME_NONNULL_BEGIN 9 | 10 | @protocol BALocalCampaignsPersisting 11 | 12 | @required 13 | 14 | - (void)persistCampaigns:(nonnull NSDictionary *)rawCampaignsData; 15 | 16 | - (nullable NSDictionary *)loadCampaignsWithError:(NSError **)error; 17 | 18 | - (void)deleteCampaigns; 19 | 20 | @end 21 | 22 | NS_ASSUME_NONNULL_END 23 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Helpers/BAWindowHelper.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAWindowHelper.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface BAWindowHelper : NSObject 13 | 14 | + (nullable UIWindowScene *)activeScene; 15 | 16 | + (nullable UIWindowScene *)activeWindowScene; 17 | 18 | + (nullable UIWindow *)keyWindow; 19 | 20 | + (nullable UIViewController *)frontmostViewController; 21 | 22 | @end 23 | 24 | NS_ASSUME_NONNULL_END 25 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Local Campaigns/Models/BALocalCampaignDayOfWeek.h: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | typedef NS_ENUM(NSUInteger, BALocalCampaignDayOfWeek) { 8 | BALocalCampaignDayOfWeekSunday = 0, 9 | BALocalCampaignDayOfWeekMonday = 1, 10 | BALocalCampaignDayOfWeekTuesday = 2, 11 | BALocalCampaignDayOfWeekWednesday = 3, 12 | BALocalCampaignDayOfWeekThursday = 4, 13 | BALocalCampaignDayOfWeekFriday = 5, 14 | BALocalCampaignDayOfWeekSaturday = 6, 15 | }; 16 | -------------------------------------------------------------------------------- /Sources/batchTests/Mocks/DeeplinkDelegateStub.m: -------------------------------------------------------------------------------- 1 | // 2 | // DeeplinkDelegateStub.m 3 | // BatchTests 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import "DeeplinkDelegateStub.h" 9 | 10 | @implementation DeeplinkDelegateStub 11 | 12 | - (instancetype)init { 13 | self = [super init]; 14 | if (self) { 15 | self.hasOpenBeenCalled = false; 16 | } 17 | return self; 18 | } 19 | 20 | - (void)openBatchDeeplink:(NSString *)deeplink { 21 | self.hasOpenBeenCalled = true; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Helpers/BANullHelper.h: -------------------------------------------------------------------------------- 1 | // 2 | // BANullHelper.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2016 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BANullHelper : NSObject 12 | 13 | + (BOOL)isArrayEmpty:(id)object; 14 | 15 | + (BOOL)isDataEmpty:(id)object; 16 | 17 | + (BOOL)isDictionaryEmpty:(id)object; 18 | 19 | + (BOOL)isStringEmpty:(id)object; 20 | 21 | + (BOOL)isNumberEmpty:(id)object; 22 | 23 | + (BOOL)isNull:(id)object; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/UI/BAMSGBannerViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGBannerViewController.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | /** 13 | Floating banner 14 | 15 | Format meant to be displayed in its own window, rather than modally. 16 | Usually vertically attached to a side of the screen 17 | */ 18 | @interface BAMSGBannerViewController : BAMSGBaseBannerViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/Query Models/BAWSQueryStart.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAWebserviceQueryNewStart.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | 13 | /*! 14 | @class BAWSQueryStart 15 | @abstract Query requesting for start 16 | */ 17 | @interface BAWSQueryStart : BAWSQuery 18 | 19 | - (instancetype)init; 20 | 21 | @property BOOL isSilent; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Objects/InAppCloseOptionCross.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Represents an in-app close cross button 8 | public struct InAppCloseOptionCross: Codable { 9 | // MARK: - 10 | 11 | let color: [String] 12 | let backgroundColor: [String]? 13 | 14 | // MARK: - 15 | 16 | public init(color: [String], backgroundColor: [String]?) { 17 | self.color = color 18 | self.backgroundColor = backgroundColor 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/Widgets/BAMSGButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGButton.h 3 | // ViewTest 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | @interface BAMSGButton : UIButton 13 | 14 | + (void)setFontOverride:(nullable UIFont *)font 15 | boldFont:(nullable UIFont *)boldFont 16 | italicFont:(nullable UIFont *)italicFont 17 | boldItalicFont:(nullable UIFont *)boldItalicFont; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Crypto/BASHA.h: -------------------------------------------------------------------------------- 1 | // 2 | // BASHA.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface BASHA : NSObject 13 | 14 | /** 15 | Returns the raw SHA256 of a given NSData 16 | */ 17 | + (nullable NSData *)sha256HashOf:(nullable NSData *)data; 18 | 19 | /** 20 | Returns the raw SHA1 of a given NSData 21 | */ 22 | + (nullable NSData *)sha1HashOf:(nullable NSData *)data; 23 | 24 | @end 25 | 26 | NS_ASSUME_NONNULL_END 27 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/Widgets/BAMSGPannableContainerView.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGPannableContainerView.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @protocol BAMSGPannableContainerViewDelegate 11 | 12 | - (void)pannableContainerWasDismissed:(BAMSGBaseContainerView *_Nonnull)container; 13 | 14 | @end 15 | 16 | @protocol BAMSGPannableContainerView 17 | 18 | @property (weak, nullable) id delegate; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/Widgets/BAMSGImageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGImageView.h 3 | // Batch 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | #import 12 | #import 13 | 14 | @interface BAMSGImageView : BAMSGGradientImageView 15 | 16 | @property UIRectCorner roundedCorners; 17 | @property BOOL alwaysShowImage; 18 | @property BOOL enableIntrinsicContentSize; 19 | 20 | - (void)setup; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Metrics/BAMetricManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | #import 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface BAMetricManager : NSObject 13 | 14 | /// Singleton shared instance 15 | + (instancetype)sharedInstance; 16 | 17 | /// Add a metric to the registered metric list 18 | - (void)addMetric:(BAMetric *)metric; 19 | 20 | /// Send metrics that have changed 21 | - (void)sendMetrics; 22 | 23 | @end 24 | 25 | NS_ASSUME_NONNULL_END 26 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Crypto/BAWebserviceCryptor.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAWebserviceCipher.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | NS_ASSUME_NONNULL_BEGIN 9 | 10 | @protocol BAWebserviceCryptor 11 | 12 | - (nullable instancetype)initWithKey:(NSString *)key version:(NSString *)version; 13 | 14 | // On error, the result will be null. No error message is supported for now 15 | - (nullable NSData *)encrypt:(NSData *)data; 16 | 17 | - (nullable NSData *)decrypt:(NSData *)data; 18 | 19 | @end 20 | 21 | NS_ASSUME_NONNULL_END 22 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Foundation/BASecureDateProvider.h: -------------------------------------------------------------------------------- 1 | // 2 | // BASecureDateProvider.h 3 | // Batch 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | #import 12 | 13 | /** 14 | Secure Date provider implementation of the BADateProviderProtocol. 15 | Will return the secure date unless unavailable, otherwise returns the system date 16 | */ 17 | @interface BASecureDateProvider : BASystemDateProvider 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/BAGETWebserviceClient.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAGETWebserviceClient.h 3 | // Batch 4 | // 5 | // Copyright © 2017 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | @interface BAGETWebserviceClient : BAWebserviceJsonClient 13 | 14 | - (nullable instancetype)initWithURL:(nonnull NSURL *)url 15 | identifier:(nonnull NSString *)identifier 16 | delegate:(nullable id)delegate NS_DESIGNATED_INITIALIZER; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Sources/batchTests/Kernel/Helpers/swiftSwizzling.swift: -------------------------------------------------------------------------------- 1 | // 2 | // swiftSwizzling.swift 3 | // BatchTests 4 | // 5 | // Created by arnaud on 15/09/2020. 6 | // Copyright © 2020 Batch.com. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | @objc 13 | class SwiftStubApplicationDelegate: NSObject, UIApplicationDelegate { 14 | @objc public var didFailToRegisterRecorded = false 15 | 16 | @objc 17 | func application(_: UIApplication, didFailToRegisterForRemoteNotificationsWithError _: Error) { 18 | didFailToRegisterRecorded = true 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Sources/batchTests/Modules/Messaging/InApp/InAppMessageBuilderOverriderTest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BatchTests 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | import Testing 8 | 9 | @testable import Batch 10 | 11 | struct InAppMessageBuilderOverriderTest { 12 | @Test func overrideValues() async throws { 13 | #expect(InAppMessageBuilderOverrider.values(format: .fullscreen, values: 2) == nil) 14 | } 15 | 16 | @Test func keepValues() async throws { 17 | #expect(InAppMessageBuilderOverrider.values(format: .modal, values: 2) == 2) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Objects/InAppCloseOption.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Represents an in-app close option 8 | /// Could be a delay, a cross button or both 9 | public struct InAppCloseOption: Codable { 10 | // MARK: - 11 | 12 | let auto: InAppCloseOptionDelay? 13 | let button: InAppCloseOptionCross? 14 | 15 | // MARK: - 16 | 17 | public init(auto: InAppCloseOptionDelay?, button: InAppCloseOptionCross?) { 18 | self.auto = auto 19 | self.button = button 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Protocols/InAppExpandableView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// A protocol for views that support an expanded state to show more content. 8 | /// Use for ``InAppContainerizable`` to automatically extend existant view 9 | protocol InAppExpandableView { 10 | /// A Boolean value that determines whether the view can be expanded. 11 | /// 12 | /// Conforming types should return `true` if they support an expanded state, and `false` otherwise. 13 | var isExpandable: Bool { get } 14 | } 15 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Metrics/BAMetricWebserviceClient.h: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | #import 7 | 8 | #import 9 | 10 | @interface BAMetricWebserviceClient : BAWebserviceJsonClient 11 | 12 | - (nullable instancetype)initWithMetrics:(nonnull NSArray *)metrics 13 | success:(void (^_Nullable)(void))successHandler 14 | error:(void (^_Nullable)(NSError *_Nonnull error))errorHandler; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/UI/BAMSGImageViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGImageViewController.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @class BAMSGMessageImage; 12 | @class BACSSDocument; 13 | 14 | @interface BAMSGImageViewController : BAMSGViewController 15 | 16 | - (instancetype _Nonnull)initWithMessage:(BAMSGMessageImage *_Nonnull)message andStyle:(BACSSDocument *_Nonnull)style; 17 | 18 | @property (nonatomic, readonly) BAMSGMessageImage *_Nonnull message; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/BAStartService.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAStartService.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | /** 15 | This service has no associated delegate, because it does not care about success nor failure 16 | */ 17 | @interface BAStartServiceDatasource : NSObject 18 | 19 | @property BOOL isSilent; 20 | 21 | @end 22 | 23 | NS_ASSUME_NONNULL_END 24 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/UI/BAMSGWebviewViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGWebviewViewController.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @class BAMSGMessageWebView; 12 | @class BACSSDocument; 13 | 14 | @interface BAMSGWebviewViewController : BAMSGViewController 15 | 16 | - (instancetype _Nonnull)initWithMessage:(BAMSGMessageWebView *_Nonnull)message andStyle:(BACSSDocument *_Nonnull)style; 17 | 18 | @property (nonatomic, readonly) BAMSGMessageWebView *_Nonnull message; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/User/BAUserDataOperation.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAUserDataOperation.m 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2015 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @implementation BAUserDataOperation 12 | 13 | - (instancetype)initWithBlock:(BOOL (^)(void))block { 14 | self = [super init]; 15 | if (self) { 16 | _operationBlock = block; 17 | } 18 | return self; 19 | } 20 | 21 | - (BOOL)run { 22 | if (!_operationBlock) 23 | return YES; 24 | 25 | return _operationBlock(); 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/Response Models/BAWSResponseStart.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAWebserviceResponseNewStart.m 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @implementation BAWSResponseStart 12 | 13 | // Default constructor. 14 | - (instancetype)initWithResponse:(NSDictionary *)response { 15 | self = [super initWithResponse:response]; 16 | 17 | if ([BANullHelper isNull:self] == YES) { 18 | return nil; 19 | } 20 | 21 | return self; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/Response Models/BAWSResponseTracking.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAWSResponseTracking.m 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @implementation BAWSResponseTracking 12 | 13 | // Default constructor. 14 | - (instancetype)initWithResponse:(NSDictionary *)response { 15 | self = [super initWithResponse:response]; 16 | 17 | if ([BANullHelper isNull:self] == YES) { 18 | return nil; 19 | } 20 | 21 | return self; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CSS/BACSSParser.h: -------------------------------------------------------------------------------- 1 | // 2 | // BACSSParser.h 3 | // CSS Test 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | 12 | @interface BACSSParser : NSObject 13 | 14 | + (instancetype)parserWithString:(NSString *)cssString andImportProvider:(id)importProvider; 15 | - (instancetype)initWithString:(NSString *)cssString andImportProvider:(id)importProvider; 16 | 17 | - (BACSSDocument *)parseWithError:(NSError **)error; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/Response Models/BAWSResponsePushToken.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAWebserviceResponsePush.m 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @implementation BAWSResponsePushToken 12 | 13 | // Default constructor. 14 | - (instancetype)initWithResponse:(NSDictionary *)response { 15 | self = [super initWithResponse:response]; 16 | 17 | if ([BANullHelper isNull:self] == YES) { 18 | return nil; 19 | } 20 | 21 | return self; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Sources/batchTests/batchTestsBootstrap.m: -------------------------------------------------------------------------------- 1 | // 2 | // batchTestsBootstrap.m 3 | // BatchTests 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | @import Batch.Batch_Private; 9 | 10 | // Class that gets instantiated before all tests 11 | // Do one time setup here 12 | @interface batchTestsBootstrap : NSObject 13 | 14 | @end 15 | 16 | @implementation batchTestsBootstrap 17 | 18 | - (instancetype)init { 19 | self = [super init]; 20 | if (self) { 21 | [self setup]; 22 | } 23 | return self; 24 | } 25 | 26 | - (void)setup { 27 | BALogger.internalLogsEnabled = true; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Concurrent/BATaskDebouncer.h: -------------------------------------------------------------------------------- 1 | // 2 | // BATaskDebouncer.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | Allows deboucing of a task defined by a block. 12 | 13 | Warning: Calling "shedule" in between threads isn't supported. 14 | */ 15 | @interface BATaskDebouncer : NSObject 16 | 17 | + (instancetype)debouncerWithDelay:(NSTimeInterval)delayTime 18 | queue:(dispatch_queue_t)queue 19 | task:(dispatch_block_t)taskBlock; 20 | 21 | - (void)schedule; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Local Campaigns/Signals/BALocalCampaignSignalProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // BALocalCampaignSignalProtocol.h 3 | // Batch 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | /** 13 | Represents an signal 14 | 15 | A signal is anything that happens during the lifecycle of an app that 16 | can trigger a local campaign 17 | */ 18 | @protocol BALocalCampaignSignalProtocol 19 | 20 | @required 21 | 22 | - (BOOL)doesSatisfyTrigger:(nullable id)trigger; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/BAMSGPayloadParser.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGPayloadParser.h 3 | // Batch 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @interface BAMSGPayloadParser : NSObject 12 | 13 | + (BAMSGMEPMessage *_Nullable)messageForMEPRawMessage:(BatchMessage *_Nonnull)rawMessage 14 | bailIfNotAlert:(BOOL)bailNotAlert; 15 | + (BAMSGCEPMessage *_Nullable)messageForCEPRawMessage:(BatchMessage *_Nonnull)rawMessage 16 | bailIfNotAlert:(BOOL)bailNotAlert; 17 | @end 18 | -------------------------------------------------------------------------------- /Sources/Batch/BANotificationCenter.m: -------------------------------------------------------------------------------- 1 | // 2 | // AGEventNotificationCenter.m 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @implementation BANotificationCenter 12 | 13 | #pragma mark - 14 | #pragma mark Public methods 15 | 16 | // Instance management. 17 | + (instancetype)defaultCenter { 18 | static id sharedInstance = nil; 19 | static dispatch_once_t onceToken; 20 | dispatch_once(&onceToken, ^{ 21 | sharedInstance = [[self alloc] init]; 22 | }); 23 | 24 | return sharedInstance; 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/Response Models/BAWSResponseTracking.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAWSResponseTracking.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /*! 12 | @class BAWSResponseTracking 13 | @abstract Response of a BAWebserviceQueryTracking. 14 | @discussion Build and serialize the response to the query. 15 | */ 16 | @interface BAWSResponseTracking : BAWSResponse 17 | 18 | /*! 19 | @method init 20 | @warning Never call this method. 21 | */ 22 | - (instancetype)init NS_UNAVAILABLE; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/UI/BAMSGModalViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGModalViewController.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | /** 15 | Modal format 16 | 17 | Uses the banner as a base to render the alert, but draws a background and is presented modally. 18 | Like a more advanced system alert, based on the banner look & implementation. 19 | */ 20 | @interface BAMSGModalViewController : BAMSGBaseBannerViewController 21 | 22 | @end 23 | 24 | NS_ASSUME_NONNULL_END 25 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Crypto/BAWebserviceStubCryptor.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAWebserviceDummyCryptor.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | // Stub cryptor that does absolutely nothing except returning the original data 15 | @interface BAWebserviceStubCryptor : NSObject 16 | 17 | - (instancetype)init NS_UNAVAILABLE; 18 | 19 | - (instancetype)initWithKey:(NSString *)key version:(NSString *)version NS_DESIGNATED_INITIALIZER; 20 | 21 | @end 22 | 23 | NS_ASSUME_NONNULL_END 24 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query/BAStandardQueryWebserviceIdentifiersProvider.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAStandardQueryWebserviceIdentifiersProvider.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | /** 14 | Class that handles collecting all the required Query WS Identifiers (di, da, etc...) 15 | */ 16 | @interface BAStandardQueryWebserviceIdentifiersProvider : NSObject 17 | 18 | + (instancetype)sharedInstance; 19 | 20 | @end 21 | 22 | NS_ASSUME_NONNULL_END 23 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/Response Models/BAWSResponsePushToken.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAWebserviceResponsePush.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /*! 12 | @class BAWebserviceResponsePush 13 | @abstract Response of a BAWebserviceQueryPush. 14 | @discussion Build and serialize the response to the query. 15 | */ 16 | @interface BAWSResponsePushToken : BAWSResponse 17 | 18 | /*! 19 | @method init 20 | @warning Never call this method. 21 | */ 22 | - (instancetype)init NS_UNAVAILABLE; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/Response Models/BAWSResponseStart.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAWebserviceResponseNewStart.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /*! 12 | @class BAWebserviceResponseNewStart 13 | @abstract Response of a BAWebserviceQueryNewStart. 14 | @discussion Build and serialize the response to the query. 15 | */ 16 | @interface BAWSResponseStart : BAWSResponse 17 | 18 | /*! 19 | @method init 20 | @warning Never call this method. 21 | */ 22 | - (instancetype)init NS_UNAVAILABLE; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/GIF/BATGIFAnimator.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | NS_ASSUME_NONNULL_BEGIN 5 | 6 | @class BATGIFAnimator; 7 | 8 | @protocol BATGIFAnimatorDelegate 9 | 10 | @required 11 | - (void)animator:(BATGIFAnimator *)animator needsToDisplayImage:(UIImage *)image; 12 | 13 | @end 14 | 15 | @interface BATGIFAnimator : NSObject 16 | 17 | @property (weak) id delegate; 18 | 19 | @property NSUInteger framerate; 20 | 21 | - (instancetype)initWithFile:(BATGIFFile *)file; 22 | 23 | - (void)startAnimating; 24 | 25 | - (void)stopAnimating; 26 | 27 | @end 28 | 29 | NS_ASSUME_NONNULL_END 30 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Opt Out/BAOptOutWebserviceClient.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAOptOutWebserviceClient.m 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | @implementation BAOptOutWebserviceClient 13 | 14 | - (instancetype)initWithEvents:(NSArray *)events promises:(NSArray *)promises { 15 | BAEventTrackerService *service = [[BAEventTrackerService alloc] initWithEvents:events promises:promises]; 16 | return [super initWithDatasource:service delegate:service]; 17 | } 18 | 19 | - (BOOL)canBypassOptOut { 20 | return true; 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Crypto/BAWebserviceAESGCMCryptor.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAWebserviceAESGCMCryptor.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | /** 15 | AES-GCM Cryptor 16 | Also encodes its output as Base 64 17 | */ 18 | @interface BAWebserviceAESGCMCryptor : NSObject 19 | 20 | - (nonnull instancetype)init NS_UNAVAILABLE; 21 | 22 | - (nullable instancetype)initWithKey:(NSString *)key version:(NSString *)version NS_DESIGNATED_INITIALIZER; 23 | 24 | @end 25 | 26 | NS_ASSUME_NONNULL_END 27 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Foundation/BAMutableDateProvider.m: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | #import "BAMutableDateProvider.h" 8 | 9 | @implementation BAMutableDateProvider { 10 | NSDate *_date; 11 | } 12 | 13 | - (instancetype)initWithTimestamp:(double)timestamp; 14 | { 15 | self = [super init]; 16 | if (self) { 17 | _date = [NSDate dateWithTimeIntervalSince1970:timestamp]; 18 | } 19 | return self; 20 | } 21 | 22 | - (void)setTime:(double)timestamp { 23 | _date = [NSDate dateWithTimeIntervalSince1970:timestamp]; 24 | } 25 | 26 | - (NSDate *)currentDate { 27 | return _date; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Helpers/BAHTTPHeaders.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAHTTPHeaders.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2016 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BAHTTPHeaders : NSObject 12 | 13 | /*! 14 | @method userAgent 15 | @abstract Generate a custom user agent from application an mobile infos. 16 | @return Formated string description of the user agent. 17 | */ 18 | + (NSString *)userAgent; 19 | 20 | /*! 21 | @method acceptLanguage 22 | @abstract Generate a custom accect language from device locale. 23 | @return Formated string. 24 | */ 25 | + (NSString *)acceptLanguage; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Debug/BADBGNameValueListItem.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @implementation BADBGNameValueCell 4 | 5 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { 6 | self = [super initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:reuseIdentifier]; 7 | return self; 8 | } 9 | 10 | @end 11 | 12 | @implementation BADBGNameValueListItem 13 | 14 | + (instancetype)itemWithName:(NSString *)name value:(NSString *)value { 15 | BADBGNameValueListItem *item = [[BADBGNameValueListItem alloc] init]; 16 | item.name = name; 17 | item.value = value; 18 | return item; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Sources/Batch/BatchLogger.h: -------------------------------------------------------------------------------- 1 | // 2 | // BatchLogger.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) Batch SDK. All rights reserved. 7 | // 8 | 9 | /// Protocol to implement if you want to use ``Batch/BatchSDK/setLoggerDelegate:`` to get Batch logs in a custom object 10 | /// of yours. 11 | /// 12 | /// - Important: Be careful with your implementation: using this can impact stability and performance. You should only 13 | /// use it if you know what you are doing. 14 | @protocol BatchLoggerDelegate 15 | 16 | /// Delegated method to get Batch logs 17 | /// 18 | /// - Parameter message: Batch message 19 | - (void)logWithMessage:(nonnull NSString *)message; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/BADelegatedUIAlertController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BADelegatedUIAlertController.h 3 | // Batch 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | #import 12 | 13 | @interface BADelegatedUIAlertController : UIAlertController 14 | 15 | @property (nonnull) BAMSGMessageAlert *messageDescription; 16 | 17 | + (instancetype _Nonnull)alertControllerWithMessage:(BAMSGMessageAlert *_Nonnull)message; 18 | 19 | - (instancetype _Nonnull)initWithMessage:(BAMSGMessageAlert *_Nonnull)message; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Opt Out/BAOptOutWebserviceClient.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAOptOutWebserviceClient.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | /** 15 | Subclass of BAQueryWebserviceClient for the opted-out event tracker. 16 | It bypasses the opt-out, allowing server communication for this very specific and desirable case 17 | */ 18 | @interface BAOptOutWebserviceClient : BAQueryWebserviceClient 19 | 20 | - (instancetype)initWithEvents:(NSArray *)events promises:(NSArray *)promises; 21 | 22 | @end 23 | 24 | NS_ASSUME_NONNULL_END 25 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/BAPushTokenService.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAPushTokenService.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | /** 15 | This service has no associated delegate, because it does not care about success nor failure 16 | */ 17 | @interface BAPushTokenServiceDatasource : NSObject 18 | 19 | - (instancetype)initWithToken:(NSString *)token usesProductionEnvironment:(BOOL)usesProductionEnvironment; 20 | 21 | @end 22 | 23 | NS_ASSUME_NONNULL_END 24 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Crypto/BAWebserviceStubCryptor.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAWebserviceDummyCryptor.m 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @implementation BAWebserviceStubCryptor 11 | 12 | - (instancetype)initWithKey:(NSString *)key version:(NSString *)version { 13 | self = [super init]; 14 | if (self) { 15 | } 16 | return self; 17 | } 18 | 19 | // On error, the result will be null. No error message is supported for now 20 | - (nullable NSData *)encrypt:(NSData *)data { 21 | return data; 22 | } 23 | 24 | - (nullable NSData *)decrypt:(NSData *)data { 25 | return data; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/ViewControllers/InAppBannerViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | import UIKit 8 | 9 | /// In app banner view controller 10 | /// Inspired by ``BAMSGBannerViewController`` 11 | class InAppBannerViewController: InAppBaseBannerViewController { 12 | // MARK: - 13 | 14 | override init(configuration: InAppViewController.Configuration) { 15 | super.init(configuration: configuration) 16 | } 17 | 18 | @available(*, unavailable) 19 | @MainActor @preconcurrency dynamic required init?(coder _: NSCoder) { 20 | fatalError("init(coder:) has not been implemented") 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Opt Out/BAOptOutEventTracker.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAOptOutEventTracker.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | #import 12 | 13 | /** 14 | Event tracker that works for opt-out purposes. 15 | Differences with the "classic" event tracker: 16 | - It works when opted out 17 | - It can notify the caller when an event HAS been tracked (meaning that the server _accepted_ it) 18 | - It doesn't store anything on disk, and does not retry on failure 19 | */ 20 | @interface BAOptOutEventTracker : NSObject 21 | 22 | - (BAPromise *)track:(BAEvent *)event; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/Webview/BATWebviewUtils.m: -------------------------------------------------------------------------------- 1 | // 2 | // BATWebviewUtils.m 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import "BATWebviewUtils.h" 9 | 10 | @implementation BATWebviewUtils 11 | 12 | + (nullable NSString *)analyticsIdForURL:(nonnull NSString *)url { 13 | NSURLComponents *urlComponents = [NSURLComponents componentsWithString:url]; 14 | if (urlComponents == nil) { 15 | return nil; 16 | } 17 | 18 | for (NSURLQueryItem *queryItem in urlComponents.queryItems) { 19 | if ([@"batchAnalyticsID" isEqualToString:queryItem.name]) { 20 | return queryItem.value; 21 | } 22 | } 23 | 24 | return nil; 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Foundation/BASecureDateProvider.m: -------------------------------------------------------------------------------- 1 | // 2 | // BASecureDateProvider.m 3 | // Batch 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | @interface BASecureDateProvider () { 13 | BASecureDate *_secureDate; 14 | } 15 | @end 16 | 17 | @implementation BASecureDateProvider 18 | 19 | - (instancetype)init { 20 | self = [super init]; 21 | if (self) { 22 | _secureDate = [BASecureDate instance]; 23 | } 24 | 25 | return self; 26 | } 27 | 28 | - (NSDate *)currentDate { 29 | NSDate *date = [_secureDate date]; 30 | return date != nil ? date : [super currentDate]; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Core/BABundleInfo.h: -------------------------------------------------------------------------------- 1 | // 2 | // BABundleInfo.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2016 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BABundleInfo : NSObject 12 | 13 | + (BOOL)usesAPNSandbox; 14 | 15 | + (BOOL)isSharedGroupConfigured; 16 | 17 | /** 18 | Returns the shared group id to use. 19 | 20 | If it is found in the main bundle info plist under the key "BATCH_APP_GROUP_ID" and not empty, this value will be 21 | returned Otherwise, it will be "group.{bundle_id}.batch 22 | */ 23 | + (nullable NSString *)sharedGroupId; 24 | + (nullable NSURL *)sharedGroupDirectory; 25 | + (nullable NSUserDefaults *)sharedDefaults; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Sources/batchTests/InvocationRecorders.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | NS_ASSUME_NONNULL_BEGIN 4 | 5 | // Proxy that records all messages that are sent to it 6 | @interface InvocationRecordingProxy : NSProxy 7 | 8 | + (instancetype)proxyWithObject:(id)object; 9 | 10 | @property (readonly) NSSet *proxy_invokedSelectors; 11 | 12 | @end 13 | 14 | // Same as InvocationRecordingProxy but when you can't use an NSProxy 15 | // (usually only because of swizzling) 16 | // Methods must be recorded manually 17 | @interface InvocationRecordingObject : NSObject 18 | 19 | @property (readonly) NSSet *invokedSelectors; 20 | 21 | - (void)recordSelector:(SEL)selector; 22 | 23 | @end 24 | 25 | NS_ASSUME_NONNULL_END 26 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Dependency Injection/Private/BAInjectableImplementations.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAInjectableImplementations.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | /** 13 | A BAInjectable that simply returns a value 14 | */ 15 | @interface BAInstanceInjectable : BAInjectable 16 | 17 | - (nonnull instancetype)initWithInstance:(nullable id)instance; 18 | 19 | @end 20 | 21 | /** 22 | A BAInjectable that uses a block to return a value 23 | */ 24 | @interface BABlockInitializerInjectable : BAInjectable 25 | 26 | - (nonnull instancetype)initWithInitializer:(nonnull BAInjectableInitializer)initializer; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/BAMSGImageDownloader.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGImageDownloader.h 3 | // Batch 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @interface BAMSGImageDownloader : NSObject 12 | 13 | + (void)downloadImageForURL:(NSURL *_Nonnull)url 14 | downloadTimeout:(NSTimeInterval)timeout 15 | completionHandler:(void (^__nonnull)(NSData *_Nullable rawData, 16 | BOOL isGif, 17 | UIImage *_Nullable image, 18 | NSError *_Nullable error))completionHandler; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/Widgets/BAMSGBaseContainerView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import 4 | #import 5 | 6 | @protocol BAMSGContainerViewProtocol 7 | @required 8 | 9 | - (CALayer *)contentLayer; 10 | 11 | @end 12 | 13 | @interface BAMSGBaseContainerView 14 | : UIView 15 | 16 | @property float cornerRadius; 17 | 18 | @property float shadowRadius; 19 | 20 | @property UIColor *shadowColor; 21 | 22 | @property float shadowOpacity; 23 | 24 | @property BOOL touchPassthrough; 25 | 26 | @property (nonatomic) BOOL rasterizeShadow; 27 | 28 | - (void)removeAllSubviews; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Helpers/BAPartialApplicationDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAPartialApplicationDelegate.h 3 | // Batch 4 | // 5 | // Created by arnaud on 15/09/2020. 6 | // Copyright © 2020 Batch.com. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | // Partial representation of UIApplicationDelegate, only implementing what we need 14 | @protocol BAPartialApplicationDelegate 15 | 16 | @required 17 | - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken; 18 | 19 | - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error; 20 | 21 | @end 22 | 23 | NS_ASSUME_NONNULL_END 24 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/Widgets/BAMSGRemoteImageView.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface BAMSGRemoteImageView : BAMSGImageView 5 | 6 | /** 7 | Same as calling -setImageURL:completion: with a nil completion block. 8 | */ 9 | - (void)setImageURL:(NSURL *)url; 10 | 11 | /** 12 | Ask the image view to load the image at `url` and display it. 13 | @param url The url pointing to the remote or local (file url) image. Local and remote gif images are also supported. 14 | @param completion Can be nil. If image couldn't be downloaded, completion is called with a non-null error. 15 | */ 16 | - (void)setImageURL:(NSURL *)url completion:(void (^)(UIImage *, NSError *))completion; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Dependency Injection/BAOverlayedInjectable.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAOverlayedInjectable.m 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @implementation BAOverlayedInjectable { 12 | BAOverlayedInjectableCallback _callback; 13 | } 14 | 15 | - (nonnull instancetype)initWithCallback:(nonnull BAOverlayedInjectableCallback)callback { 16 | self = [super init]; 17 | if (self) { 18 | _callback = callback; 19 | } 20 | return self; 21 | } 22 | 23 | - (nullable id)resolveWithOriginalInstance:(nullable id)originalInstance { 24 | return _callback(originalInstance); 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/BAWebserviceURLBuilder.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAWebserviceURLBuilder.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface BAWebserviceURLBuilder : NSObject 13 | 14 | + (nullable NSURL *)webserviceURLForHost:(nonnull NSString *)host; 15 | 16 | + (nullable NSURL *)webserviceURLForHost:(nonnull NSString *)host shortname:(nonnull NSString *)shortname; 17 | 18 | + (nullable NSURL *)webserviceURLForHost:(nonnull NSString *)host 19 | shortname:(nonnull NSString *)shortname 20 | apiKey:(nonnull NSString *)apiKey; 21 | 22 | @end 23 | 24 | NS_ASSUME_NONNULL_END 25 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Crypto/BAWebserviceAESGCMGzipCryptor.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAWebserviceAESGCMGzipCryptor.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | #import 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | /** 16 | AES-GCM GzipCryptor 17 | Also encodes its output as Base 64 18 | */ 19 | @interface BAWebserviceAESGCMGzipCryptor : BAWebserviceAESGCMCryptor 20 | 21 | - (nonnull instancetype)init NS_UNAVAILABLE; 22 | 23 | - (nullable instancetype)initWithKey:(NSString *)key version:(NSString *)version NS_DESIGNATED_INITIALIZER; 24 | 25 | @end 26 | 27 | NS_ASSUME_NONNULL_END 28 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Helpers/BARandom.h: -------------------------------------------------------------------------------- 1 | // 2 | // BARandom.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2016 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BARandom : NSObject 12 | 13 | /*! 14 | @method generateRandomStringLength: 15 | @abstract Generate a random [0-9][a-z][A-Z] string. 16 | @param length : Lenght of the string to generate. 17 | @return The generated string. 18 | */ 19 | + (NSString *)randomAlphanumericStringWithLength:(int)length; 20 | 21 | /*! 22 | @method generateUUID 23 | @abstract Generate a random identifier using CFUUIDCreateString() method. 24 | @return The generated string supposed to be unique. 25 | */ 26 | + (NSString *)generateUUID; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Tracker/BATrackerSignpostHelper.h: -------------------------------------------------------------------------------- 1 | // 2 | // BATrackerSignpostHelper.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @protocol BATrackerSignpostHelperProtocol 13 | 14 | - (void)trackEvent:(NSString *)event withParameters:(NSDictionary *)parameters collapsable:(BOOL)collapsable; 15 | 16 | @end 17 | 18 | /** 19 | Signpost helper for Batch's event tracker 20 | Allows easier event debugging in instruments 21 | 22 | Do not instanciate on versions iOS < 12 23 | */ 24 | API_AVAILABLE(ios(12.0)) 25 | @interface BATrackerSignpostHelper : NSObject 26 | 27 | @end 28 | 29 | NS_ASSUME_NONNULL_END 30 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query/BAQueryWebserviceClientDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAQueryWebserviceClientDelegate.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @class BAQueryWebserviceClient; 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @protocol BAQueryWebserviceClientDelegate 15 | 16 | @optional 17 | 18 | - (void)webserviceClientWillStart:(BAQueryWebserviceClient *)client; 19 | 20 | @required 21 | 22 | - (void)webserviceClient:(BAQueryWebserviceClient *)client didFailWithError:(NSError *)error; 23 | 24 | - (void)webserviceClient:(BAQueryWebserviceClient *)client 25 | didSucceedWithResponses:(NSArray> *)responses; 26 | 27 | @end 28 | 29 | NS_ASSUME_NONNULL_END 30 | -------------------------------------------------------------------------------- /Tools/Bridgy/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.1 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "Bridgy", 8 | dependencies: [ 9 | // Dependencies declare other packages that this package depends on. 10 | // .package(url: /* package url */, from: "1.0.0"), 11 | ], 12 | targets: [ 13 | // Targets are the basic building blocks of a package. A target can define a module or a test suite. 14 | // Targets can depend on other targets in this package, and on products in packages which this package depends on. 15 | .target( 16 | name: "Bridgy", 17 | dependencies: []), 18 | ] 19 | ) 20 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Protocols/InAppExpandableComponent.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// A protocol that defines the properties of a component within an expandable view. 8 | protocol InAppExpandableComponent { 9 | /// The string representation of the component's desired height, corresponding to the raw value of an ``InAppHeightType``. 10 | /// 11 | /// This value is parsed to determine the sizing behavior. Examples include: 12 | /// - `"auto"`: The height is determined by the component's intrinsic content size. 13 | /// - `"fill"`: The component expands to fill remaining vertical space. 14 | /// - `"250px"`: The height is a fixed value. 15 | var height: String { get } 16 | } 17 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Helpers/InAppEdgeIndexHelper.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Helper to centralize index logic 8 | enum InAppEdgeIndexHelper: Int { 9 | case top = 0 10 | case right, bottom, left 11 | } 12 | 13 | /// Ease the get of edge inset 14 | extension Collection { 15 | subscript(edge value: InAppEdgeIndexHelper) -> CGFloat { 16 | self.map(CGFloat.init)[edge: value] 17 | } 18 | } 19 | 20 | /// Ease the get of edge inset 21 | extension Collection { 22 | subscript(edge value: InAppEdgeIndexHelper) -> CGFloat { 23 | let index = index(startIndex, offsetBy: value.rawValue) 24 | return indices.contains(index) ? self[index] : 0 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/Response Models/BAWSResponseLocalCampaigns.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAWSResponseLocalCampaigns.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | /*! 13 | @class BAWSResponseLocalCampaigns 14 | @abstract Response of a BAWSResponseLocalCampaigns. 15 | @discussion Build and serialize the response to the query. 16 | */ 17 | @interface BAWSResponseLocalCampaigns : BAWSResponse 18 | 19 | /*! 20 | @method init 21 | @warning Never call this method. 22 | */ 23 | - (instancetype _Nullable)init NS_UNAVAILABLE; 24 | 25 | @property (nonnull, readonly) NSDictionary *payload; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Sources/batchTests/Webservices/Query Services/pushTokenServiceTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // pushTokenServiceTests.swift 3 | // BatchTests 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | import Batch.Batch_Private 9 | import Foundation 10 | import XCTest 11 | 12 | private let expectedToken = "test_token" 13 | 14 | class pushTokenServiceTests: XCTestCase { 15 | func testIdentifier() { 16 | XCTAssertEqual(makeService().requestIdentifier, "push") 17 | } 18 | 19 | func testShortIdentifier() { 20 | XCTAssertEqual(makeService().requestShortIdentifier, "t") 21 | } 22 | 23 | func makeService() -> BAPushTokenServiceDatasource { 24 | return BAPushTokenServiceDatasource(token: expectedToken, usesProductionEnvironment: false) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Tools/Bridgy/Sources/Bridgy/Config.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public struct Config : Codable { 4 | let outputDir: String 5 | let basePath: String 6 | let headers: [String: HeaderConfig] 7 | 8 | enum CodingKeys: String, CodingKey { 9 | case outputDir = "output_directory" 10 | case basePath = "base_search_path" 11 | case headers 12 | } 13 | } 14 | 15 | public struct HeaderConfig : Codable { 16 | let path: String 17 | let recursive: Bool 18 | let ignoredNames: String? 19 | let frameworkName: String? 20 | } 21 | 22 | internal func readConfigAtPath(path: String) -> Data? { 23 | let fm = FileManager.default 24 | if fm.fileExists(atPath: path) { 25 | return fm.contents(atPath: path) 26 | } 27 | return nil 28 | } 29 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Local Campaigns/Signals/BAEventTrackedSignal.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAEventTrackedSignal.m 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @implementation BAEventTrackedSignal 12 | 13 | - (instancetype)initWithName:(NSString *)name { 14 | self = [super init]; 15 | if (self) { 16 | self.name = name; 17 | } 18 | 19 | return self; 20 | } 21 | 22 | - (BOOL)doesSatisfyTrigger:(nullable id)trigger { 23 | if (![trigger isKindOfClass:[BAEventTrigger class]]) { 24 | return false; 25 | } 26 | 27 | return [((BAEventTrigger *)trigger) isSatisfiedForName:self.name label:nil]; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Helpers/BADateFormatting.m: -------------------------------------------------------------------------------- 1 | // 2 | // BADateFormatting.m 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | #import "Defined.h" 10 | 11 | @implementation BADateFormatting 12 | 13 | + (NSDateFormatter *)dateFormatter; 14 | { 15 | static NSDateFormatter *dateFormatter = nil; 16 | static dispatch_once_t onceToken; 17 | dispatch_once(&onceToken, ^{ 18 | dateFormatter = [[NSDateFormatter alloc] init]; 19 | dateFormatter.locale = [NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"]; 20 | dateFormatter.dateFormat = kParametersDateFormat; 21 | dateFormatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0]; 22 | }); 23 | 24 | return dateFormatter; 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Helpers/BAStringUtils.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAStringUtils.m 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2016 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | 13 | @implementation BAStringUtils 14 | 15 | // Generate the hexadeciaml value of the data. 16 | + (NSString *)hexStringValueForData:(NSData *)data { 17 | NSMutableString *stringBuffer = [NSMutableString stringWithCapacity:([data length] * 2)]; 18 | 19 | const unsigned char *dataBuffer = [data bytes]; 20 | int i; 21 | 22 | for (i = 0; i < [data length]; ++i) { 23 | [stringBuffer appendFormat:@"%02x", (unsigned int)dataBuffer[i]]; 24 | } 25 | 26 | return [stringBuffer copy]; 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Parameters/BAPropertiesCenter.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAPropertiesCenter.h 3 | // Core 4 | // 5 | // Copyright (c) 2012 Batch SDK. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | 12 | /*! 13 | @class BAPropertiesCenter 14 | @abstract Accessor for application data. 15 | @discussion Provide a set of data, device, system ... 16 | */ 17 | @interface BAPropertiesCenter : NSObject 18 | 19 | + (nullable NSString *)valueForShortName:(nonnull NSString *)selectorString; 20 | 21 | /** 22 | For tests 23 | */ 24 | - (nonnull NSString *)notifType; 25 | - (nonnull NSString *)notifTypeFallback; 26 | - (nullable BANotificationAuthorizationSettings *)notificationAuthorizationSettings; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Objects/InAppWebview.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Represents an in-app webview component 8 | public struct InAppWebview: Codable, Identifiable, InAppTypedComponent { 9 | // MARK: - 10 | 11 | public let id: String 12 | public let type: InAppComponent 13 | public let inAppDeeplinks: Bool 14 | public let devMode: Bool 15 | public let timeout: TimeInterval 16 | 17 | // MARK: - 18 | 19 | public init(id: String, inAppDeeplink: Bool, devMode: Bool, timeout: TimeInterval) { 20 | self.id = id 21 | self.type = .webview 22 | self.inAppDeeplinks = inAppDeeplink 23 | self.devMode = devMode 24 | self.timeout = timeout 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/Widgets/BAMSGLabel.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGLabel.h 3 | // ViewTest 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | #import 12 | 13 | @interface BAMSGLabel : UILabel 14 | 15 | @property UIEdgeInsets padding; 16 | 17 | + (void)setFontOverride:(nullable UIFont *)font 18 | boldFont:(nullable UIFont *)boldFont 19 | italicFont:(nullable UIFont *)italicFont 20 | boldItalicFont:(nullable UIFont *)boldItalicFont; 21 | 22 | - (void)setText:(NSString *_Nullable)text transforms:(NSArray *_Nullable)transforms; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Batch SDK use in source and binary forms, with or without modification, is permitted only to allow use of the Batch platform by Batch customers. 2 | 3 | Batch SDK can be embedded in Batch customers mobile apps, but redistribution of Batch SDK in source and binary forms, with or without modification is prohibited without the prior written permission of Batch. 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/Webview/BATWebviewBridgeWKHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // BATWebviewBridgeWKHandler.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | #import 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | @interface BATWebviewBridgeWKHandler : NSObject 16 | 17 | - (instancetype)initWithBridge:(nonnull BATWebviewJavascriptBridge *)bridge; 18 | 19 | - (void)userContentController:(WKUserContentController *)userContentController 20 | didReceiveScriptMessage:(WKScriptMessage *)message 21 | replyHandler:(void (^)(id _Nullable, NSString *_Nullable))replyHandler; 22 | 23 | @end 24 | 25 | NS_ASSUME_NONNULL_END 26 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/Widgets/BAMSGCloseButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGCloseButton.h 3 | // ViewTest 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @interface BAMSGCloseButton : UIButton 12 | 13 | @property (nonnull, nonatomic) UIColor *glyphColor; 14 | @property (nullable) NSNumber *glyphWidth; 15 | @property (nullable) NSNumber *glyphPadding; 16 | /// Default to false. Set to true to display a 1-px wide border the color of the glyph @ 75% opacity. 17 | @property (nonatomic) BOOL showBorder; 18 | 19 | - (void)prepareCountdown; 20 | - (void)animateCountdownForDuration:(CFTimeInterval)duration 21 | completionHandler:(nullable void (^)(void))completionHandler; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Dependency Injection/BAInjectable.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAInjectable.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | typedef _Nullable id (^BAInjectableInitializer)(void); 11 | 12 | @interface BAInjectable : NSObject 13 | 14 | /** 15 | Make an injectable using an initializer block. The initializer will be called on each injection. 16 | */ 17 | + (nonnull BAInjectable *)injectableWithInitializer:(nonnull BAInjectableInitializer)initializer; 18 | 19 | /** 20 | Make an injectable for an instance. The given instance will be returned directly. 21 | */ 22 | + (nonnull BAInjectable *)injectableWithInstance:(nullable id)instance; 23 | 24 | /** 25 | Resolve the instance 26 | */ 27 | - (nullable id)resolveInstance; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Local Campaigns/Signals/BAPublicEventTrackedSignal.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAPublicEventTrackedSignal.h 3 | // Batch 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | @class BatchEventAttributes; 13 | 14 | @interface BAPublicEventTrackedSignal : NSObject 15 | 16 | @property (nonnull, copy) NSString *name; 17 | 18 | @property (nullable, copy) NSString *label; 19 | 20 | @property (nullable, copy) NSDictionary *attributes; 21 | 22 | - (nonnull instancetype)initWithName:(nonnull NSString *)name 23 | label:(nullable NSString *)label 24 | attributes:(nullable NSDictionary *)attributes; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:6.1 2 | import PackageDescription 3 | 4 | let package = Package( 5 | name: "Batch", 6 | platforms: [ 7 | .iOS(.v15) 8 | ], 9 | products: [ 10 | // Products define the executables and libraries a package produces, and make them visible to other packages. 11 | .library( 12 | name: "Batch", 13 | targets: ["Batch"]) 14 | ], 15 | dependencies: [ 16 | // Dependencies declare other packages that this package depends on. 17 | ], 18 | targets: [ 19 | .binaryTarget( 20 | name: "Batch", 21 | url: "https://download.batch.com/sdk/ios/spm/BatchSDK-ios_spm-xcframework-3.2.0.zip", 22 | checksum: "e34cd08076dd191de59f2a5b27e78df14d7b6b0ee3f0ebe461a2288b2572b70a" 23 | ) 24 | ] 25 | ) -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Objects/InAppDivider.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Represents an in-app divider 8 | public struct InAppDivider: Codable, InAppTypedComponent { 9 | // MARK: - 10 | 11 | public let type: InAppComponent 12 | let color: [String] 13 | let thickness: Int? 14 | let margin: [Int]? 15 | let width: String 16 | let align: InAppHorizontalAlignment? 17 | 18 | // MARK: - 19 | 20 | public init(color: [String], thickness: Int?, margin: [Int]?, width: String, align: InAppHorizontalAlignment?) { 21 | self.type = .divider 22 | self.color = color 23 | self.thickness = thickness 24 | self.margin = margin 25 | self.width = width 26 | self.align = align 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/UI/BAMSGStackViewItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGStackViewItem.h 3 | // ViewTest 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | 12 | @interface BAMSGStackViewItem : NSObject 13 | 14 | @property (nonnull) BACSSRules *rules; 15 | @property (nullable) UIView *view; 16 | @property BOOL attachToParentBottom; 17 | 18 | - (nonnull NSArray *)computeConstraints; 19 | 20 | // "Private" properties, that will be set by the stack view 21 | @property (nullable, weak) UIView *previousView; 22 | @property (nullable, weak) UIView *nextView; 23 | @property (nullable, weak) UIView *parentView; 24 | 25 | @end 26 | 27 | @interface BAMSGStackViewSeparatorItem : BAMSGStackViewItem 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Objects/InAppImage.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Represents an in-app image 8 | public struct InAppImage: Codable, Identifiable, InAppTypedComponent, InAppExpandableComponent { 9 | // MARK: - 10 | 11 | public let id: String 12 | public let type: InAppComponent 13 | let aspect: InAppAspectRatio? 14 | let margin: [Int]? 15 | let height: String 16 | let radius: [Int]? 17 | 18 | // MARK: - 19 | 20 | public init(id: String, aspect: InAppAspectRatio?, margin: [Int]?, height: String, radius: [Int]?) { 21 | self.id = id 22 | self.type = .image 23 | self.aspect = aspect 24 | self.margin = margin 25 | self.height = height 26 | self.radius = radius 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Sources/Batch/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | BASDKVersion 19 | CFBundleVersion 20 | BAAPILevel 21 | 22 | 23 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Concurrent/BAPromise.h: -------------------------------------------------------------------------------- 1 | // https://batch.com 2 | // Copyright (c) 2018 Batch SDK. All rights reserved. 3 | 4 | #import 5 | 6 | typedef NS_ENUM(NSUInteger, BAPromiseStatus) { 7 | BAPromiseStatusPending, 8 | BAPromiseStatusResolved, 9 | BAPromiseStatusRejected, 10 | }; 11 | 12 | @interface BAPromise : NSObject 13 | 14 | @property BAPromiseStatus status; 15 | 16 | + (nonnull instancetype)resolved:(nullable ObjectType)value; 17 | 18 | + (nonnull instancetype)rejected:(nullable NSError *)error; 19 | 20 | - (void)resolve:(nullable ObjectType)value; 21 | 22 | - (void)reject:(nullable NSError *)error; 23 | 24 | - (void)then:(void (^_Nonnull)(ObjectType _Nullable value))thenBlock; 25 | 26 | - (void)catch:(void (^_Nonnull)(NSError *_Nullable))catchBlock; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Core/BASessionManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // BASessionManager.h 3 | // Batch 4 | // 5 | // Copyright © 2017 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | Notification sent by Batch Push when it gets a remote notification. This includes the one your app is started with 12 | (even though it is only sent when Batch starts) 13 | */ 14 | FOUNDATION_EXPORT NSString *_Nonnull const BATNewSessionStartedNotification; 15 | 16 | /** 17 | This class manages a user session. 18 | 19 | A new session starts: 20 | - On a cold app start 21 | - If an app comes into foreground more than X seconds after the last 22 | (Where X is defined in a global constant) 23 | */ 24 | @interface BASessionManager : NSObject 25 | 26 | @property (nonatomic, readonly, nullable) NSString *sessionID; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Sources/OCMock/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | 22 | 23 | -------------------------------------------------------------------------------- /Sources/batchTests/Modules/User/userDataManagerTests.swift: -------------------------------------------------------------------------------- 1 | import Batch.Batch_Private 2 | import Foundation 3 | import XCTest 4 | 5 | @testable import Batch 6 | 7 | class UserDataManagerTests: XCTestCase { 8 | func testModernAttributeMethods() async throws { 9 | let datasource = MockUserDatasource() 10 | 11 | let overlay = BAInjection.overlayProtocol(BAUserDatasourceProtocol.self, returnedInstance: datasource) 12 | defer { removeOverlay(overlay) } 13 | 14 | datasource.expect() 15 | .call( 16 | datasource.clearTags() 17 | ) 18 | datasource.expect() 19 | .call( 20 | datasource.clearAttributes() 21 | ) 22 | 23 | await BAUserDataManager._performClearRemoteInstallationData() 24 | 25 | datasource.verify() 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Views/InAppPercentedView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Must only be used in ``InAppColumns`` and ``InAppColumnsViewTests`` 8 | /// Represents the ration than the user could set for each column 9 | class InAppPercentedView: UIView { 10 | // MARK: - 11 | 12 | let percent: CGFloat 13 | 14 | // MARK: - 15 | 16 | override var intrinsicContentSize: CGSize { 17 | return CGSize(width: percent, height: -1) 18 | } 19 | 20 | // MARK: - 21 | 22 | init(percent: CGFloat) { 23 | self.percent = percent 24 | 25 | super.init(frame: .zero) 26 | } 27 | 28 | @available(*, unavailable) 29 | required init?(coder _: NSCoder) { 30 | fatalError("init(coder:) has not been implemented") 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/Query Models/BAWSQueryStart.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAWebserviceQueryNewStart.m 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | 13 | @implementation BAWSQueryStart 14 | 15 | // Standard constructor. 16 | - (instancetype)init { 17 | self = [super initWithType:kQueryWebserviceTypeStart]; 18 | self.isSilent = false; 19 | return self; 20 | } 21 | 22 | // Build the basic object to send to the server as a query. 23 | - (NSMutableDictionary *)objectToSend; 24 | { 25 | NSMutableDictionary *dictionary = [super objectToSend]; 26 | [dictionary setValue:@(self.isSilent) forKey:kWebserviceKeyQuerySilentStart]; 27 | 28 | return dictionary; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMArgAction.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import 18 | 19 | @interface OCMArgAction : NSObject 20 | 21 | - (void)handleArgument:(id)argument; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMExpectationRecorder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import "OCMStubRecorder.h" 18 | 19 | @interface OCMExpectationRecorder : OCMStubRecorder 20 | 21 | - (id)never; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Core/BATUserActivity.m: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | #import "BATUserActivity.h" 8 | #import 9 | 10 | @implementation BATUserActivity 11 | 12 | + (void)initialize { 13 | Method boolGetterMethod = class_getInstanceMethod([self class], @selector(exampleBoolGetter)); 14 | 15 | SEL targetSelector = NSSelectorFromString([NSString stringWithFormat:@"_%@%@", @"is", @"UniversalLink"]); 16 | IMP implementation = imp_implementationWithBlock(^(id self) { 17 | return [self hasUniversalLink]; 18 | }); 19 | class_addMethod([self class], targetSelector, implementation, method_getTypeEncoding(boolGetterMethod)); 20 | } 21 | 22 | // Useless method that is used to get its type encoding 23 | - (BOOL)exampleBoolGetter { 24 | return true; 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Builder/InAppUIEdgeInsetsBuilder.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Must only be used in ``InAppMessageChecker`` 8 | extension InAppMessageChecker { 9 | /// UI edge insets helper 10 | struct InAppUIEdgeInsetsBuilder { 11 | /// Build ``UIEdgeInsets`` from array 12 | /// - Parameter array: Insets 13 | /// - Returns: UIEdgeInsets 14 | static func build(from array: [Int]?) -> UIEdgeInsets { 15 | return array.map { 16 | UIEdgeInsets( 17 | top: $0[edge: .top], 18 | left: $0[edge: .left], 19 | bottom: $0[edge: .bottom], 20 | right: $0[edge: .right] 21 | ) 22 | } ?? .zero 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CSS/BACSSToken.h: -------------------------------------------------------------------------------- 1 | // 2 | // BACSSSpecialToken.h 3 | // CSS Test 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | typedef NS_ENUM(NSUInteger, BACSSSpecialTokenKind) { 11 | BACSSSpecialTokenKindUnknown = 0, 12 | BACSSSpecialTokenKindBlockStart = 1, // { 13 | BACSSSpecialTokenKindBlockEnd = 2, // } 14 | BACSSSpecialTokenKindPropertyEnd = 3, // ; 15 | BACSSSpecialTokenKindPropertySeparator = 4, // : 16 | BACSSSpecialTokenKindNewline = 5 // \n 17 | }; 18 | 19 | @interface BACSSSpecialToken : NSObject 20 | 21 | + (instancetype)specialTokenWithChar:(char)specialToken; 22 | 23 | - (instancetype)initWithChar:(char)specialToken; 24 | 25 | @property char value; 26 | 27 | @property BACSSSpecialTokenKind kind; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/Response Models/BAWSResponseLocalCampaigns.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAWSResponseLocalCampaigns.m 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | 13 | @interface BAWSResponseLocalCampaigns () { 14 | NSDictionary *_payload; 15 | } 16 | @end 17 | 18 | @implementation BAWSResponseLocalCampaigns 19 | 20 | // Default constructor. 21 | - (instancetype)initWithResponse:(NSDictionary *)response { 22 | self = [super initWithResponse:response]; 23 | 24 | if (self) { 25 | _payload = response; 26 | } 27 | 28 | return self; 29 | } 30 | 31 | - (NSDictionary *)payload { 32 | return _payload != nil ? _payload : @{}; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/User/BAUserAttribute.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAUserAttribute.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2015 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | 13 | @interface BAUserAttribute : NSObject 14 | 15 | + (nonnull instancetype)attributeWithValue:(nonnull id)value type:(BAUserAttributeType)type; 16 | 17 | + (nonnull NSDictionary *)serverJsonRepresentationForAttributes: 18 | (nullable NSDictionary *)attributes; 19 | 20 | @property (nonatomic, nonnull) id value; 21 | 22 | @property (assign, nonatomic) BAUserAttributeType type; 23 | 24 | @end 25 | 26 | typedef NSDictionary BAUserAttributes; 27 | typedef NSDictionary *> BAUserTagCollections; 28 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/BAResponseHelper.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAResponseHelper.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /*! 12 | @class BAResponseHelper 13 | @abstract Response helper for Start webservice. 14 | @discussion Provide helpfull functions for Start webservice. 15 | */ 16 | @interface BAResponseHelper : NSObject 17 | 18 | /*! 19 | @method init 20 | @warning Never call this method. 21 | */ 22 | - (instancetype)init NS_UNAVAILABLE; 23 | 24 | /*! 25 | @method checkResponse: 26 | @abstract Check the validity of the response. 27 | @param response : The dictionary representation of the response. 28 | @return An error if something goes wrong, nil otherwise. 29 | */ 30 | + (NSError *)checkResponse:(NSDictionary *)response; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Core/BAURLSession.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAURLSession.m 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface NSURLSession () 11 | 12 | @end 13 | 14 | @implementation BAURLSession 15 | 16 | + (id)sharedSession { 17 | static NSURLSession *session; 18 | static dispatch_once_t onceToken; 19 | dispatch_once(&onceToken, ^{ 20 | NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration ephemeralSessionConfiguration]; 21 | // Enforce TLS 1.2 22 | sessionConfig.TLSMinimumSupportedProtocolVersion = tls_protocol_version_TLSv12; 23 | 24 | session = [NSURLSession sessionWithConfiguration:sessionConfig delegate:nil delegateQueue:nil]; 25 | }); 26 | return session; 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Sources/Batch/BANotificationCenter.h: -------------------------------------------------------------------------------- 1 | // 2 | // BANotificationCenter.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Batch notifications: 12 | #define kNotificationBatchStarts @"notification.start" 13 | #define kNotificationBatchStops @"notification.stop" 14 | 15 | /*! 16 | @class BANotificationCenter 17 | @abstract The private notification center. 18 | */ 19 | @interface BANotificationCenter : NSNotificationCenter 20 | 21 | /*! 22 | @method init 23 | @warning Never call this method. 24 | */ 25 | - (instancetype)init NS_UNAVAILABLE; 26 | 27 | /*! 28 | @method defaultCenter 29 | @abstract Singleton accessor. 30 | @return The unique instance of this object. 31 | */ 32 | + (instancetype)defaultCenter __attribute__((warn_unused_result)); 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Sources/Batch/BatchMessagingCloseReason.h: -------------------------------------------------------------------------------- 1 | // 2 | // BatchMessagingCloseReason.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2016 Batch SDK. All rights reserved. 7 | // 8 | 9 | // Determin the different reasons why an In-App message can be closed 10 | typedef NS_CLOSED_ENUM(NSUInteger, BatchMessagingCloseReason) { 11 | // The message was closed automatically from auto dismiss feature. 12 | BatchMessagingCloseReasonAuto, 13 | // The message was closed by the user (like clicking on the close or back button). 14 | BatchMessagingCloseReasonUser, 15 | // The message was closed because the user clicked on a CTA. 16 | BatchMessagingCloseReasonAction, 17 | // The message was closed because of an error 18 | // (for example, a message with only one image in it that fails to be downloaded). 19 | BatchMessagingCloseReasonError 20 | }; 21 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMock.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCMock.h 3 | // OCMock 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | //! Project version number for OCMock. 11 | FOUNDATION_EXPORT double OCMockVersionNumber; 12 | 13 | //! Project version string for OCMock. 14 | FOUNDATION_EXPORT const unsigned char OCMockVersionString[]; 15 | 16 | // In this header, you should import all the public headers of your framework using statements like #import "PublicHeader.h" 17 | #import "OCMockObject.h" 18 | #import "OCMockMacros.h" 19 | #import "OCMRecorder.h" 20 | #import "OCMVerifier.h" 21 | #import "OCMStubRecorder.h" 22 | #import "OCMConstraint.h" 23 | #import "OCMArg.h" 24 | #import "OCMLocation.h" 25 | #import "OCMQuantifier.h" 26 | #import "OCMMacroState.h" 27 | #import "NSNotificationCenter+OCMAdditions.h" 28 | #import "OCMFunctions.h" 29 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/Query Models/BAWSQueryPushToken.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAWebserviceQueryPush.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | /*! 16 | @class BAWebserviceQueryPush 17 | @abstract Query that gives the push token. 18 | @discussion Used to enable push 19 | */ 20 | @interface BAWSQueryPushToken : BAWSQuery 21 | 22 | /*! 23 | @abstract Standard constructor. 24 | @param token : Token to send. 25 | @param production : Is the token APNS production or sandbox? 26 | @return Instance or nil. 27 | */ 28 | - (instancetype)initWithToken:(NSString *)token andIsProduction:(BOOL)production; 29 | 30 | @end 31 | 32 | NS_ASSUME_NONNULL_END 33 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMArgAction.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import "OCMArgAction.h" 18 | 19 | 20 | @implementation OCMArgAction 21 | 22 | - (void)handleArgument:(id)argument 23 | { 24 | 25 | } 26 | 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Sources/batchTests/Modules/Messaging/InApp/InAppSpacerViewTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BatchTests 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | import Testing 8 | 9 | @testable import Batch 10 | 11 | struct InAppSpacerViewTests { 12 | static let heightType: InAppHeightType = .fill 13 | 14 | @MainActor 15 | @Test func testConfiguration() async throws { 16 | let spacerView = InAppSpacerView( 17 | configuration: InAppSpacerView.Configuration( 18 | placement: InAppSpacerView.Configuration.Placement(heightType: Self.heightType) 19 | ) 20 | ) 21 | 22 | #expect(spacerView.configuration.placement.isExpandable == true) 23 | #expect(spacerView.configuration.placement is InAppExpandableView) 24 | #expect(spacerView.configuration.placement.verticalAlignment == .top) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Tools/XcodeTemplates/Batch Unit Test Case Class.xctemplate/XCTestCaseSwift/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BatchTests 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | @testable import Batch 8 | import Batch.Batch_Private 9 | import XCTest 10 | 11 | final class ___FILEBASENAMEASIDENTIFIER___: XCTestCase { 12 | 13 | func testExample() throws { 14 | // This is an example of a functional test case. 15 | // Use XCTAssert and related functions to verify your tests produce the correct results. 16 | // Any test you write for XCTest can be annotated as throws and async. 17 | // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. 18 | // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Event Dispatcher/BAPushEventPayload.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAPushEventPayload.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | #import 12 | 13 | @interface BAPushEventPayload : NSObject 14 | 15 | @property (readonly, nullable) NSString *trackingId; 16 | @property (readonly, nullable) NSString *deeplink; 17 | @property (readonly) BOOL isPositiveAction; 18 | @property (readonly, nullable) BatchMessage *sourceMessage; 19 | @property (readonly, nullable) NSDictionary *notificationUserInfo; 20 | @property (readonly, nullable) NSString *webViewAnalyticsIdentifier; 21 | 22 | - (nonnull instancetype)initWithUserInfo:(nonnull NSDictionary *)userInfo; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Objects/InAppColumns.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Represents an in-app columns 8 | public struct InAppColumns: Codable, InAppTypedComponent { 9 | // MARK: - 10 | 11 | public let type: InAppComponent 12 | let children: [InAppAnyTypedComponent?] 13 | let ratios: [Int]? 14 | let margin: [Int]? 15 | let spacing: Int? 16 | let contentAlign: InAppVerticalAlignment? 17 | 18 | // MARK: - 19 | 20 | public init(children: [InAppAnyTypedComponent?], ratios: [Int]?, margin: [Int]?, spacing: Int?, align: InAppVerticalAlignment?) { 21 | self.type = .columns 22 | self.children = children 23 | self.ratios = ratios 24 | self.margin = margin 25 | self.spacing = spacing 26 | self.contentAlign = align 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMBoxedReturnValueProvider.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import "OCMObjectReturnValueProvider.h" 18 | 19 | @interface OCMBoxedReturnValueProvider : OCMObjectReturnValueProvider 20 | { 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/Query Models/BAWSQueryTracking.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAWSQueryTracking.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | /*! 16 | @class BAWSQueryTracking 17 | @abstract Query that send events to the server. 18 | @discussion Used to send the events from the tracker 19 | */ 20 | @interface BAWSQueryTracking : BAWSQuery 21 | 22 | /*! 23 | @method init 24 | @warning Never call this method. 25 | */ 26 | - (instancetype)init NS_UNAVAILABLE; 27 | 28 | /*! 29 | @abstract Standard constructor. 30 | @param events : Events to send. 31 | */ 32 | - (instancetype)initWithEvents:(nonnull NSArray *)events; 33 | 34 | @end 35 | 36 | NS_ASSUME_NONNULL_END 37 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMObjectReturnValueProvider.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import "OCMNonRetainingObjectReturnValueProvider.h" 18 | 19 | @interface OCMObjectReturnValueProvider : OCMNonRetainingObjectReturnValueProvider 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMPassByRefSetter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import "OCMArgAction.h" 18 | 19 | @interface OCMPassByRefSetter : OCMArgAction 20 | { 21 | id value; 22 | } 23 | 24 | - (id)initWithValue:(id)value; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Helpers/BAOSHelper.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAOSHelper.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2016 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BAOSHelper : NSObject 12 | 13 | /*! 14 | @method deviceCode 15 | @abstract Get the device code string. 16 | @return The current standard code. 17 | */ 18 | + (nonnull NSString *)deviceCode; 19 | 20 | /// Parse an integer representation of an iOS version 21 | /// Format is XXXYYYZZZ, where XXX is major, YYY minor, ZZZ patch. 22 | /// @param outVersion NSOperatingSystemVersion to write to. Must not be NULL or the method will return false. 23 | /// @return true on success, false on failure. outVersion will only be written to on success. 24 | + (BOOL)parseIntegerSystemVersion:(NSInteger)intSystemVersion out:(NSOperatingSystemVersion *_Nonnull)outVersion; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Sources/OCMock/NSValue+OCMAdditions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import 18 | 19 | @interface NSValue(OCMAdditions) 20 | 21 | - (BOOL)getBytes:(void *)outputBuf objCType:(const char *)targetType; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Local Campaigns/Outputs/BALocalCampaignOutputProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // BALocalCampaignOutputProtocol.h 3 | // Batch 4 | // 5 | // Copyright © 2017 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | @class BALocalCampaign; 13 | 14 | NS_ASSUME_NONNULL_BEGIN 15 | 16 | /** 17 | Represents a local campaign output 18 | 19 | An output is the action executed by a triggered local campaign 20 | */ 21 | @protocol BALocalCampaignOutputProtocol 22 | 23 | @required 24 | 25 | - (nullable instancetype)initWithPayload:(nonnull NSDictionary *)payload 26 | isCEPMessage:(BOOL)isCEPMessage 27 | error:(NSError **)error; 28 | 29 | - (void)performForCampaign:(nonnull BALocalCampaign *)campaign; 30 | 31 | @end 32 | 33 | NS_ASSUME_NONNULL_END 34 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Dependency Injection/BAInjectable.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAInjectable.m 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | @implementation BAInjectable 13 | 14 | #pragma mark Classes 15 | 16 | + (nonnull BAInjectable *)injectableWithInitializer:(nonnull BAInjectableInitializer)initializer { 17 | return [[BABlockInitializerInjectable alloc] initWithInitializer:initializer]; 18 | } 19 | 20 | + (nonnull BAInjectable *)injectableWithInstance:(nullable id)instance { 21 | return [[BAInstanceInjectable alloc] initWithInstance:instance]; 22 | } 23 | 24 | #pragma mark Instance resolving 25 | 26 | - (id)resolveInstance { 27 | return nil; 28 | } 29 | 30 | #pragma mark Other 31 | 32 | - (NSString *)description { 33 | return @"BAInjectable"; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMRealObjectForwarder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import 18 | 19 | @interface OCMRealObjectForwarder : NSObject 20 | { 21 | } 22 | 23 | - (void)handleInvocation:(NSInvocation *)anInvocation; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Sources/sdk.xctestplan: -------------------------------------------------------------------------------- 1 | { 2 | "configurations" : [ 3 | { 4 | "id" : "BDAE40BC-F176-40A4-A920-19B111E3069F", 5 | "name" : "Configuration 1", 6 | "options" : { 7 | 8 | } 9 | } 10 | ], 11 | "defaultOptions" : { 12 | "language" : "en", 13 | "locationScenario" : { 14 | "identifier" : "New York, NY, USA", 15 | "referenceType" : "built-in" 16 | }, 17 | "region" : "US", 18 | "testTimeoutsEnabled" : true, 19 | "threadSanitizerEnabled" : true, 20 | "uiTestingScreenshotsLifetime" : "keepAlways", 21 | "userAttachmentLifetime" : "keepAlways" 22 | }, 23 | "testTargets" : [ 24 | { 25 | "parallelizable" : false, 26 | "target" : { 27 | "containerPath" : "container:Batch.xcodeproj", 28 | "identifier" : "02F7846A19B9EF5A0006FF07", 29 | "name" : "BatchTests" 30 | } 31 | } 32 | ], 33 | "version" : 1 34 | } 35 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/Widgets/BAMSGStylableView.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGStylableView.h 3 | // ViewTest 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | 12 | @protocol BAMSGStylableView 13 | 14 | - (void)applyRules:(nonnull BACSSRules *)rules; 15 | 16 | @end 17 | 18 | @interface BAMSGStylableViewHelper : NSObject 19 | 20 | + (void)applyCommonRules:(nonnull BACSSRules *)rules toView:(nonnull UIView *)view; 21 | 22 | + (nullable UIColor *)colorFromValue:(nonnull NSString *)value; 23 | 24 | + (nullable UIColor *)colorFromRGBAValue:(nonnull NSString *)rgbaValue; 25 | 26 | + (nullable UIFont *)fontFromRules:(nonnull BACSSRules *)rules 27 | baseFont:(nullable UIFont *)baseFont 28 | baseBoldFont:(nullable UIFont *)baseBoldFont; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Sources/batchTests/Mocks/BatchUserDataEditorMock.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BatchTests 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | import Batch.Batch_Private 8 | import Foundation 9 | 10 | @testable import Batch 11 | 12 | class BAInstallDataEditorMock: BAInstallDataEditor { 13 | var setIdentifierCalled: Bool = false 14 | var identifierToSet: String? 15 | var saveCalled: Bool = false 16 | 17 | override init() { 18 | super.init() 19 | self.reset() 20 | } 21 | 22 | override func setIdentifier(_ identifier: String?) { 23 | setIdentifierCalled = true 24 | identifierToSet = identifier 25 | } 26 | 27 | override func save() { 28 | // Do nothing 29 | saveCalled = true 30 | } 31 | 32 | func reset() { 33 | setIdentifierCalled = false 34 | identifierToSet = nil 35 | saveCalled = false 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Objects/InAppRootContainer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Represents an in-app root container 8 | public struct InAppRootContainer: Codable { 9 | // MARK: - 10 | 11 | let backgroundColor: [String]? 12 | let children: [InAppAnyTypedComponent] 13 | let margin: [Int]? 14 | let radius: [Int]? 15 | let borderWidth: Int? 16 | let borderColor: [String]? 17 | 18 | // MARK: - 19 | 20 | public init(backgroundColor: [String]?, children: [InAppAnyTypedComponent], margin: [Int]?, radius: [Int]?, borderWidth: Int?, borderColor: [String]?) { 21 | self.backgroundColor = backgroundColor 22 | self.children = children 23 | self.margin = margin 24 | self.radius = radius 25 | self.borderWidth = borderWidth 26 | self.borderColor = borderColor 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Core/BAURLSessionProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAURLSessionProtocol.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | NS_ASSUME_NONNULL_BEGIN 9 | 10 | /** 11 | Protocol defining expected methods on a NSURLSession-like object to perform network requests 12 | 13 | Production implementations should forward the calls to a configured NSURLSession instance. 14 | Allows to easily mock NSURLSession 15 | */ 16 | @protocol BAURLSessionProtocol 17 | 18 | @required 19 | - (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request 20 | completionHandler:(void (^)(NSData *_Nullable data, 21 | NSURLResponse *_Nullable response, 22 | NSError *_Nullable error))completionHandler; 23 | 24 | @end 25 | 26 | NS_ASSUME_NONNULL_END 27 | -------------------------------------------------------------------------------- /Tools/Scripts/strip_public_swift_framework.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## This script removes public Swift stuff from a Batch framework. 4 | ## Run it into a "Batch.framework" directory 5 | 6 | ## 1/ It removes Headers/Batch-Swift.h 7 | ## 2/ It removes PrivateHeaders/ 8 | ## 3/ It removes _CodeSignature/ 9 | ## 4/ It removes Modules/Batch.swiftmodule/ 10 | ## 5/ It removes what is between //#start-remove-prod and //#end-remove-prod in Modules/module.modulemap 11 | ## 6/ It removes the Batch.Swift module 12 | 13 | ## 1/ 14 | rm Headers/Batch-Swift.h 2>/dev/null 15 | 16 | ## 2/ 17 | rm -r PrivateHeaders 2>/dev/null 18 | 19 | ## 3/ 20 | rm -r _CodeSignature 2>/dev/null 21 | 22 | ## 4/ 23 | rm -r Modules/Batch.swiftmodule 2>/dev/null 24 | 25 | ## 5/ 26 | perl -pi -000 -e "s/\\/\\/#start-remove-prod.*#end-remove-prod//s" Modules/module.modulemap 27 | 28 | ## 6/ 29 | perl -pi -000 -e "s/module Batch\\.Swift \\{.*}//s" Modules/module.modulemap -------------------------------------------------------------------------------- /Sources/Batch/Batch.h: -------------------------------------------------------------------------------- 1 | // 2 | // Batch.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Batch. 12 | FOUNDATION_EXPORT double BatchVersionNumber; 13 | 14 | //! Project version string for Batch. 15 | FOUNDATION_EXPORT const unsigned char BatchVersionString[]; 16 | 17 | #import 18 | #import 19 | #import 20 | #import 21 | #import 22 | #import 23 | #import 24 | #import 25 | #import 26 | #import 27 | #import 28 | #import 29 | #import 30 | #import 31 | -------------------------------------------------------------------------------- /Sources/batchTests/Info-test.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSPrincipalClass 6 | batchTestsBootstrap 7 | CFBundleDevelopmentRegion 8 | en 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | BNDL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | 26 | 27 | -------------------------------------------------------------------------------- /Sources/batchTests/Modules/Profile/TestProfileCenter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BatchTests 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | import Batch 8 | import Foundation 9 | 10 | @testable import Batch.Batch_Private 11 | 12 | /// A test BATProfileEditor that has a controllable canSetEmail 13 | class TestProfileCenter: BAProfileCenterProtocol { 14 | public var onProjectChangedHasBeenCalled = false 15 | 16 | func identify(_: String?) {} 17 | 18 | func trackPublicEvent(name _: String, attributes _: BatchEventAttributes?) throws {} 19 | 20 | func trackLocation(_: CLLocation) {} 21 | 22 | func validateEventAttributes(_: BatchEventAttributes) -> [String] { 23 | return [] 24 | } 25 | 26 | func applyEditor(_: BATProfileEditor) {} 27 | 28 | func onProjectChanged(oldProjectKey _: String?, newProjectKey _: String?) { 29 | onProjectChangedHasBeenCalled = true 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Tools/Dockerfile.format: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM swift:6.2.0-jammy 3 | 4 | ENV DEBIAN_FRONTEND=noninteractive 5 | 6 | # Install clang-format and setup for non-root users 7 | RUN apt-get update -y && apt-get install -y clang-format-14 && \ 8 | mv /usr/bin/clang-format-14 /usr/bin/clang-format && \ 9 | # Create a generic user directory structure 10 | mkdir -p /tmp/home && \ 11 | chmod 777 /tmp/home 12 | 13 | # Copy configuration files and scripts 14 | COPY .clang-format /data/.clang-format 15 | COPY .clang-format-version /data/.clang-format-version 16 | COPY .swift-version /data/.swift-version 17 | COPY .swift-format /data/.swift-format 18 | COPY Tools /data/Tools 19 | 20 | # Make scripts executable and set proper permissions 21 | RUN chmod +x /data/Tools/Scripts/*.sh 22 | 23 | # Set HOME for non-root users and ensure permissions 24 | ENV HOME=/tmp/home 25 | WORKDIR /data 26 | ENTRYPOINT ["/bin/bash"] 27 | -------------------------------------------------------------------------------- /Sources/OCMock/OCProtocolMockObject.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import "OCMockObject.h" 18 | 19 | @interface OCProtocolMockObject : OCMockObject 20 | { 21 | Protocol *mockedProtocol; 22 | } 23 | 24 | - (id)initWithProtocol:(Protocol *)aProtocol; 25 | 26 | @end 27 | 28 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/BAEventTrackerService.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAEventTrackerService.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | #import 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | /** 16 | Event tracker service datasource+delegate 17 | They are both mixed as the delegate needs data from the datasource 18 | */ 19 | @interface BAEventTrackerService : NSObject 20 | 21 | - (instancetype)initWithEvents:(NSArray *)events; 22 | 23 | /** 24 | Note that a promise-enabled service will NOT notify the scheduler of success 25 | */ 26 | - (instancetype)initWithEvents:(NSArray *)events promises:(nullable NSArray *)promises; 27 | 28 | @end 29 | 30 | NS_ASSUME_NONNULL_END 31 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/Query Models/BAWSQueryAttributesCheck.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAWSQueryAttributesCheck.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | 13 | /*! 14 | @class BAWSQueryAttributesCheck 15 | @abstract Query that send attributes to the server. 16 | */ 17 | @interface BAWSQueryAttributesCheck : BAWSQuery 18 | 19 | /*! 20 | @method init 21 | @warning Never call this method. 22 | */ 23 | - (nonnull instancetype)init NS_UNAVAILABLE; 24 | 25 | /*! 26 | @abstract Standard constructor. 27 | @param transaction : The transaction ID 28 | @param version : Database version 29 | @return Instance or nil. 30 | */ 31 | - (nonnull instancetype)initWithTransactionID:(nonnull NSString *)transaction andVersion:(long long)version; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMExceptionReturnValueProvider.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import "OCMObjectReturnValueProvider.h" 18 | 19 | extern NSString *OCMStubbedException; 20 | 21 | @interface OCMExceptionReturnValueProvider : OCMObjectReturnValueProvider 22 | { 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/Query Models/BAWSQuery.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAWebserviceQuery.m 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | 13 | @implementation BAWSQuery 14 | 15 | // Root initialization of all queries. 16 | - (instancetype)initWithType:(NSString *)type { 17 | self = [super init]; 18 | 19 | if (self) { 20 | _identifier = [BARandom generateUUID]; 21 | _type = type; 22 | } 23 | 24 | return self; 25 | } 26 | 27 | // Build the basic object to send to the server as a query. 28 | - (NSMutableDictionary *)objectToSend { 29 | NSMutableDictionary *outDict = [NSMutableDictionary new]; 30 | outDict[kWebserviceKeyQueryIdentifier] = _identifier; 31 | outDict[kWebserviceKeyQueryType] = _type; 32 | return outDict; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMBlockArgCaller.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import "OCMArgAction.h" 18 | 19 | @interface OCMBlockArgCaller : OCMArgAction 20 | { 21 | NSArray *arguments; 22 | } 23 | 24 | - (instancetype)initWithBlockArguments:(NSArray *)someArgs; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Crypto/BASHA.m: -------------------------------------------------------------------------------- 1 | // 2 | // BASHA.m 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @implementation BASHA 12 | 13 | + (nullable NSData *)sha256HashOf:(nullable NSData *)data { 14 | if (data == nil || data.length == 0) { 15 | return nil; 16 | } 17 | 18 | uint8_t digest[CC_SHA256_DIGEST_LENGTH]; 19 | CC_SHA256(data.bytes, (int)data.length, digest); 20 | 21 | return [NSData dataWithBytes:digest length:CC_SHA256_DIGEST_LENGTH]; 22 | } 23 | 24 | + (nullable NSData *)sha1HashOf:(nullable NSData *)data { 25 | if (data == nil || data.length == 0) { 26 | return nil; 27 | } 28 | 29 | uint8_t digest[CC_SHA1_DIGEST_LENGTH]; 30 | CC_SHA1(data.bytes, (int)data.length, digest); 31 | 32 | return [NSData dataWithBytes:digest length:CC_SHA1_DIGEST_LENGTH]; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/Widgets/BAMSGGradientView.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAMSGGradientView.h 3 | // Batch 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | @protocol BAMSGGradientBackgroundProtocol 13 | 14 | - (void)setBackgroundGradient:(float)angle colors:(NSArray *)colors locations:(NSArray *)locations; 15 | 16 | @end 17 | 18 | @interface BAMSGGradientView : UIView 19 | 20 | + (void)setupGradientLayer:(CAGradientLayer *)layer 21 | withAngle:(float)angle 22 | colors:(NSArray *)colors 23 | locations:(NSArray *)locations; 24 | 25 | @property BOOL touchPassthrough; 26 | 27 | @end 28 | 29 | @interface BAMSGGradientImageView : UIImageView 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/BALocalCampaignsService.h: -------------------------------------------------------------------------------- 1 | // 2 | // BALocalCampaignsService.h 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | #import 12 | 13 | #import 14 | 15 | #import 16 | 17 | NS_ASSUME_NONNULL_BEGIN 18 | 19 | @interface BALocalCampaignsServiceDatasource : NSObject 20 | 21 | - (instancetype)initWithViewEvents:(nullable NSDictionary *)viewEvents; 22 | 23 | @end 24 | 25 | @interface BALocalCampaignsServiceDelegate : NSObject 26 | 27 | - (instancetype)initWithLocalCampaignsCenter:(BALocalCampaignsCenter *)center; 28 | 29 | @end 30 | 31 | NS_ASSUME_NONNULL_END 32 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMFunctions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import 18 | 19 | 20 | #if defined(__cplusplus) 21 | #define OCMOCK_EXTERN extern "C" 22 | #else 23 | #define OCMOCK_EXTERN extern 24 | #endif 25 | 26 | 27 | OCMOCK_EXTERN BOOL OCMIsObjectType(const char *objCType); 28 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/BAMessagingAnalyticsDeduplicatingDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAMessagingAnalyticsDeduplicatingDelegate.h 3 | // Batch 4 | // 5 | 6 | #import 7 | 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | /// Class that proxies the analytics call to an analytics delegate but ensures stuff like triggers only 14 | /// occurring once. 15 | /// It handles special cases such as In-App messages tracking an occurrence 16 | /// 17 | /// Also makes it easily mockable 18 | /// 19 | /// This class is the one that gets injected for the BAMessagingAnalyticsDelegate protocol 20 | @interface BAMessagingAnalyticsDeduplicatingDelegate : NSObject 21 | 22 | - (instancetype)initWithWrappedDelegate:(nonnull id)delegate 23 | BATCH_USE_INJECTION_OUTSIDE_TESTS; 24 | 25 | @end 26 | 27 | NS_ASSUME_NONNULL_END 28 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Local Campaigns/BALocalCampaignsGlobalCappings.h: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | @class BALocalCampaignsTimeBasedCapping; 10 | 11 | /// Represents the global cappings for local campaigns 12 | @interface BALocalCampaignsGlobalCappings : NSObject 13 | 14 | /// Number of in-apps allowed during the user session 15 | @property (nullable) NSNumber *session; 16 | 17 | /// List of time-based cappings 18 | @property (nullable) NSArray *timeBasedCappings; 19 | 20 | @end 21 | 22 | /** 23 | Represents a time-based capping rule 24 | Eg: display no more than 3 in-apps in 1 hour 25 | */ 26 | @interface BALocalCampaignsTimeBasedCapping : NSObject 27 | 28 | /// Number of views allowed 29 | @property (nullable) NSNumber *views; 30 | 31 | /// Capping duration ( in seconds ) 32 | @property (nullable) NSNumber *duration; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Sources/Batch/BatchDataCollectionConfig.m: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | #import "BatchDataCollectionConfig.h" 8 | 9 | @interface BatchDataCollectionConfig () { 10 | NSNumber *_geoIPEnabled; 11 | NSNumber *_deviceModelEnabled; 12 | } 13 | @end 14 | 15 | @implementation BatchDataCollectionConfig 16 | 17 | - (instancetype)init { 18 | self = [super init]; 19 | _geoIPEnabled = nil; 20 | _deviceModelEnabled = nil; 21 | return self; 22 | } 23 | 24 | - (NSNumber *_Nullable)geoIPEnabled { 25 | return _geoIPEnabled; 26 | } 27 | 28 | - (void)setGeoIPEnabled:(BOOL)geoIPEnabled { 29 | _geoIPEnabled = [NSNumber numberWithBool:geoIPEnabled]; 30 | } 31 | 32 | - (NSNumber *_Nullable)deviceModelEnabled { 33 | return _deviceModelEnabled; 34 | } 35 | 36 | - (void)setDeviceModelEnabled:(BOOL)deviceModelEnabled { 37 | _deviceModelEnabled = [NSNumber numberWithBool:deviceModelEnabled]; 38 | } 39 | @end 40 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Types/InAppWidthType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | /// Define the width logic than a component could use 8 | public enum InAppWidthType: Equatable { 9 | // MARK: - 10 | 11 | public static let percentKey = "%" 12 | public static let autoKey = "auto" 13 | 14 | case auto 15 | case percent(value: Int) 16 | 17 | var value: Int? { 18 | return switch self { 19 | case .auto: nil 20 | case let .percent(value: value): value 21 | } 22 | } 23 | 24 | // MARK: - 25 | 26 | init?(stringValue: String) { 27 | if stringValue.hasSuffix(Self.percentKey), let value = Int(stringValue.dropLast(Self.percentKey.count)) { 28 | self = .percent(value: value) 29 | } else if stringValue == Self.autoKey { 30 | self = .auto 31 | } else { 32 | return nil 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Sources/batchTests/DataUtils.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension Data { 4 | init(hexString: String) { 5 | self.init() 6 | var startIndex = hexString.startIndex 7 | if hexString.hasPrefix("0x") { 8 | startIndex = hexString.index(startIndex, offsetBy: 2) 9 | } 10 | 11 | while startIndex < hexString.endIndex { 12 | let endIndex = hexString.index(startIndex, offsetBy: 2, limitedBy: hexString.endIndex) ?? hexString.endIndex 13 | var substr = hexString[startIndex.. 18 | 19 | @interface NSObject(OCMAdditions) 20 | 21 | + (IMP)instanceMethodForwarderForSelector:(SEL)aSelector; 22 | + (void)enumerateMethodsInClass:(Class)aClass usingBlock:(void (^)(Class cls, SEL sel))aBlock; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Event Dispatcher/BAPushEventPayload.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAPushEventPayload.m 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | #import 12 | 13 | @implementation BAPushEventPayload 14 | 15 | - (instancetype)initWithUserInfo:(nonnull NSDictionary *)userInfo { 16 | self = [super init]; 17 | if (self) { 18 | _sourceMessage = nil; 19 | _notificationUserInfo = userInfo; 20 | _deeplink = nil; 21 | _trackingId = nil; 22 | _isPositiveAction = true; 23 | 24 | _deeplink = [BAPushCenter deeplinkFromUserInfo:userInfo]; 25 | } 26 | return self; 27 | } 28 | 29 | - (nullable NSObject *)customValueForKey:(nonnull NSString *)key { 30 | if ([kWebserviceKeyPushBatchData isEqualToString:key]) { 31 | return nil; 32 | } 33 | return self.notificationUserInfo[key]; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Sources/batchTests/Modules/Messaging/InApp/InAppWidthTypeTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BatchTests 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | import Testing 8 | 9 | @testable import Batch 10 | 11 | struct InAppWidthTypeTests { 12 | @Test func testInAppWidthTypeAuto() async throws { 13 | let stringValue = "auto" 14 | let widthType = InAppWidthType(stringValue: stringValue) 15 | #expect(widthType == .auto) 16 | } 17 | 18 | @Test func testInAppWidthTypePx() async throws { 19 | let value: Int = 200 20 | let stringValue = "\(value)%" 21 | let widthType = InAppWidthType(stringValue: stringValue) 22 | #expect(widthType == .percent(value: value)) 23 | } 24 | 25 | @Test func testInAppWidthTypeNil() async throws { 26 | let value: Int = 200 27 | let stringValue = "\(value)%%%" 28 | let widthType = InAppWidthType(stringValue: stringValue) 29 | #expect(widthType == nil) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMNotificationPoster.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import 18 | 19 | @interface OCMNotificationPoster : NSObject 20 | { 21 | NSNotification *notification; 22 | } 23 | 24 | - (id)initWithNotification:(id)aNotification; 25 | 26 | - (void)handleInvocation:(NSInvocation *)anInvocation; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query/BAStandardQueryWebserviceIdentifiersProvider.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAStandardQueryWebserviceIdentifiersProvider.m 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | #import 12 | #import 13 | #import 14 | #import 15 | 16 | @implementation BAStandardQueryWebserviceIdentifiersProvider 17 | 18 | + (instancetype)sharedInstance { 19 | static BAStandardQueryWebserviceIdentifiersProvider *instance; 20 | static dispatch_once_t onceToken; 21 | dispatch_once(&onceToken, ^{ 22 | instance = [BAStandardQueryWebserviceIdentifiersProvider new]; 23 | }); 24 | return instance; 25 | } 26 | 27 | - (NSDictionary *)identifiers { 28 | return [[BATDataCollectionCenter sharedInstance] buildIdsForQuery]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Sources/OCMock/OCPartialMockObject.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import "OCClassMockObject.h" 18 | 19 | @interface OCPartialMockObject : OCClassMockObject 20 | { 21 | NSObject *realObject; 22 | NSInvocation *invocationFromMock; 23 | } 24 | 25 | - (id)initWithObject:(NSObject *)anObject; 26 | 27 | - (NSObject *)realObject; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMBlockCaller.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import 18 | 19 | @interface OCMBlockCaller : NSObject 20 | { 21 | void (^block)(NSInvocation *); 22 | } 23 | 24 | - (id)initWithCallBlock:(void (^)(NSInvocation *))theBlock; 25 | 26 | - (void)handleInvocation:(NSInvocation *)anInvocation; 27 | 28 | @end 29 | 30 | -------------------------------------------------------------------------------- /Sources/Batch/BatchEventDispatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // BatchEventDispatcher.m 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2019 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | @implementation BatchEventDispatcher 14 | 15 | + (BOOL)isNotificationEvent:(BatchEventDispatcherType)eventType { 16 | return eventType == BatchEventDispatcherTypeNotificationOpen; 17 | } 18 | 19 | + (BOOL)isMessagingEvent:(BatchEventDispatcherType)eventType { 20 | return ![self isNotificationEvent:eventType]; 21 | } 22 | 23 | + (void)addDispatcher:(id)dispatcher { 24 | [[BAInjection injectClass:BAEventDispatcherCenter.class] addEventDispatcher:dispatcher]; 25 | } 26 | 27 | + (void)removeDispatcher:(id)dispatcher { 28 | [[BAInjection injectClass:BAEventDispatcherCenter.class] removeEventDispatcher:dispatcher]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/Query Models/BAWSQueryLocalCampaigns.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAWSQueryLocalCampaigns.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | #import 13 | 14 | NS_ASSUME_NONNULL_BEGIN 15 | 16 | /*! 17 | @class BAWSQueryLocalCampaigns 18 | @abstract Query requesting for local campaigns 19 | */ 20 | @interface BAWSQueryLocalCampaigns : BAWSQuery 21 | 22 | /*! 23 | @method init 24 | @warning Never call this method. 25 | */ 26 | - (instancetype)init NS_UNAVAILABLE; 27 | 28 | /*! 29 | @abstract Standard constructor. 30 | @param viewEvents : Array of viewEvents to forward to the server 31 | @return Instance or nil. 32 | */ 33 | - (instancetype)initWithViewEvents:(nullable NSDictionary *)viewEvents; 34 | 35 | @end 36 | 37 | NS_ASSUME_NONNULL_END 38 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/Response Models/BAWSResponse.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAWebserviceResponse.m 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | 13 | @implementation BAWSResponse 14 | 15 | // Default constructor. 16 | - (instancetype)initWithResponse:(NSDictionary *)response { 17 | self = [super init]; 18 | 19 | if ([BANullHelper isNull:self] == YES) { 20 | return self; 21 | } 22 | 23 | if ([BANullHelper isDictionaryEmpty:response] == YES) { 24 | return nil; 25 | } 26 | 27 | // Reference is the ID of the query this response references 28 | NSString *reference = [response objectForKey:kWebserviceKeyQueryIdentifier]; 29 | 30 | if ([BANullHelper isStringEmpty:reference] == YES) { 31 | return nil; 32 | } 33 | 34 | _reference = reference; 35 | 36 | return self; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMInvocationExpectation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import "OCMInvocationStub.h" 18 | 19 | @interface OCMInvocationExpectation : OCMInvocationStub 20 | { 21 | BOOL matchAndReject; 22 | BOOL isSatisfied; 23 | } 24 | 25 | - (void)setMatchAndReject:(BOOL)flag; 26 | - (BOOL)isMatchAndReject; 27 | 28 | - (BOOL)isSatisfied; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMNonRetainingObjectReturnValueProvider.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import 18 | 19 | @interface OCMNonRetainingObjectReturnValueProvider : NSObject 20 | { 21 | id returnValue; 22 | } 23 | 24 | - (instancetype)initWithValue:(id)aValue; 25 | 26 | - (void)handleInvocation:(NSInvocation *)anInvocation; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Sources/OCMock/NSNotificationCenter+OCMAdditions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import 18 | 19 | @class OCObserverMockObject; 20 | 21 | 22 | @interface NSNotificationCenter(OCMAdditions) 23 | 24 | - (void)addMockObserver:(OCObserverMockObject *)notificationObserver name:(NSString *)notificationName object:(id)notificationSender; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMVerifier.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import "OCMRecorder.h" 18 | 19 | @class OCMLocation; 20 | @class OCMQuantifier; 21 | 22 | @interface OCMVerifier : OCMRecorder 23 | 24 | @property(strong) OCMLocation *location; 25 | @property(strong) OCMQuantifier *quantifier; 26 | 27 | - (instancetype)withQuantifier:(OCMQuantifier *)quantifier; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Foundation/BAUptimeProvider.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAUptimeProvider.m 3 | // Batch 4 | // 5 | // Copyright © 2017 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | @implementation BAUptimeProvider 15 | 16 | // Gets the real uptime, including the time spent in deep sleep 17 | // [[NSProcessInfo processInfo] systemUptime] drifts, even 18 | // if the documentation doesn't say so. 19 | + (NSTimeInterval)uptime { 20 | struct timeval boottime; 21 | int mib[2] = {CTL_KERN, KERN_BOOTTIME}; 22 | size_t size = sizeof(boottime); 23 | time_t now; 24 | time_t uptime = -1; 25 | 26 | time(&now); 27 | 28 | if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 && boottime.tv_sec != 0) { 29 | uptime = now - boottime.tv_sec; 30 | } 31 | 32 | if (uptime == -1) { 33 | return [[NSProcessInfo processInfo] systemUptime]; 34 | } 35 | 36 | return uptime; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/ViewControllers/InAppModalViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | import UIKit 8 | 9 | /// In app modal view controller 10 | /// Inspired by ``BAMSGModalViewController`` 11 | class InAppModalViewController: InAppBaseBannerViewController { 12 | // MARK: - 13 | 14 | override var shouldDisplayInSeparateWindow: Bool { false } 15 | 16 | // MARK: - 17 | 18 | override init(configuration: InAppViewController.Configuration) { 19 | super.init(configuration: configuration) 20 | 21 | modalTransitionStyle = .crossDissolve 22 | } 23 | 24 | @available(*, unavailable) 25 | @MainActor @preconcurrency dynamic required init?(coder _: NSCoder) { 26 | fatalError("init(coder:) has not been implemented") 27 | } 28 | 29 | // MARK: - 30 | 31 | override func loadView() { 32 | super.loadView() 33 | 34 | view.backgroundColor = .black.withAlphaComponent(0.5) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Local Campaigns/BALocalCampaign.m: -------------------------------------------------------------------------------- 1 | // 2 | // BALocalCampaign.m 3 | // Batch 4 | // 5 | // Copyright © 2016 Batch. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @implementation BALocalCampaign 11 | 12 | - (void)generateOccurrenceIdentifier { 13 | NSMutableDictionary *mutableEventData; 14 | if (self.eventData != nil) { 15 | mutableEventData = [[NSMutableDictionary alloc] initWithDictionary:self.eventData]; 16 | } else { 17 | mutableEventData = [[NSMutableDictionary alloc] initWithCapacity:1]; 18 | } 19 | 20 | mutableEventData[@"i"] = [NSString stringWithFormat:@"%.0f", [[NSDate date] timeIntervalSince1970] * 1000]; 21 | 22 | self.eventData = mutableEventData; 23 | } 24 | 25 | @end 26 | 27 | @implementation BATSyncedJITResult 28 | 29 | - (nonnull instancetype)initWithTimestamp:(NSTimeInterval)timestamp { 30 | self = [super init]; 31 | if (self) { 32 | self.timestamp = timestamp; 33 | } 34 | return self; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Metrics/BAMetricRegistry.h: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | #import 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface BAMetricRegistry : NSObject 14 | 15 | @property (nonnull, readonly, class) BAMetricRegistry *instance; 16 | 17 | /// Observe local campaigns JIT response time 18 | - (BAObservation *)localCampaignsJITResponseTime; 19 | 20 | /// Count local campaign ws calls by status ("OK", "KO") 21 | - (BACounter *)localCampaignsJITCount; 22 | 23 | /// Observe local campaigns sync response time 24 | - (BAObservation *)localCampaignsSyncResponseTime; 25 | 26 | /// Count dns errors 27 | - (BACounter *)dnsErrorCount; 28 | 29 | /// Count loading image error 30 | - (BACounter *)downloadingImageErrorCount; 31 | 32 | /// New observation for download image time 33 | - (BAObservation *)registerNewDownloadImageDurationMetric; 34 | 35 | @end 36 | 37 | NS_ASSUME_NONNULL_END 38 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMIndirectReturnValueProvider.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import 18 | 19 | @interface OCMIndirectReturnValueProvider : NSObject 20 | { 21 | id provider; 22 | SEL selector; 23 | } 24 | 25 | - (id)initWithProvider:(id)aProvider andSelector:(SEL)aSelector; 26 | 27 | - (void)handleInvocation:(NSInvocation *)anInvocation; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Sources/OCMock/OCMInvocationStub.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2020 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import "OCMInvocationMatcher.h" 18 | 19 | @interface OCMInvocationStub : OCMInvocationMatcher 20 | { 21 | NSMutableArray *invocationActions; 22 | } 23 | 24 | - (void)addInvocationAction:(id)anAction; 25 | - (NSArray *)invocationActions; 26 | 27 | - (void)handleInvocation:(NSInvocation *)anInvocation; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Sources/batchTests/Kernel/Logger/loggerSetupTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // BatchTests 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | #import 8 | @import Batch.Batch_Private; 9 | #import "OCMock.h" 10 | 11 | @interface loggerSetupTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation loggerSetupTests 16 | 17 | + (void)tearDown { 18 | BALogger.internalLogsEnabled = false; 19 | } 20 | 21 | - (void)testEnableInternalLogsWithArgument { 22 | BALogger.internalLogsEnabled = false; 23 | 24 | NSMutableArray *mockArguments = [NSMutableArray new]; 25 | 26 | id nsProcessMock = OCMClassMock([NSProcessInfo class]); 27 | OCMStub([nsProcessMock processInfo]).andReturn(nsProcessMock); 28 | OCMStub([nsProcessMock arguments]).andReturn(mockArguments); 29 | 30 | [BALogger setup]; 31 | XCTAssertFalse(BALogger.internalLogsEnabled); 32 | 33 | [mockArguments addObject:@"-BatchSDKEnableInternalLogs"]; 34 | [BALogger setup]; 35 | XCTAssertTrue(BALogger.internalLogsEnabled); 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Core/BAWebserviceClientExecutor.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAWebserviceClientExecutor.m 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface BAWebserviceClientExecutor () { 11 | NSOperationQueue *_queue; 12 | } 13 | @end 14 | 15 | @implementation BAWebserviceClientExecutor 16 | 17 | + (BAWebserviceClientExecutor *)sharedInstance { 18 | static BAWebserviceClientExecutor *instance = nil; 19 | static dispatch_once_t onceToken; 20 | dispatch_once(&onceToken, ^{ 21 | instance = [BAWebserviceClientExecutor new]; 22 | }); 23 | 24 | return instance; 25 | } 26 | 27 | - (instancetype)init { 28 | self = [super init]; 29 | if (self) { 30 | _queue = [[NSOperationQueue alloc] init]; 31 | _queue.maxConcurrentOperationCount = kWebserviceClientExecutorMaxConcurrency; 32 | } 33 | return self; 34 | } 35 | 36 | - (void)addClient:(BAWebserviceClient *)client { 37 | [_queue addOperation:client]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Sources/batchTests/Modules/Inbox/inboxFetcherTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // inboxFetcherTests.swift 3 | // Batch 4 | // 5 | // Copyright © Batch.com. All rights reserved. 6 | // 7 | 8 | import Batch 9 | import Foundation 10 | import XCTest 11 | 12 | class inboxFetcherTests: XCTestCase { 13 | func testFilterSilentNotificationsProperty() { 14 | // This test makes sure that the default silent notification property value is right and that it can be set. 15 | // The implementation of this flag isn't tested here. 16 | func verifyValues(_ fetcher: BatchInboxFetcher) { 17 | XCTAssertTrue(fetcher.filterSilentNotifications) 18 | fetcher.filterSilentNotifications = false 19 | XCTAssertFalse(fetcher.filterSilentNotifications) 20 | fetcher.filterSilentNotifications = true 21 | XCTAssertTrue(fetcher.filterSilentNotifications) 22 | } 23 | 24 | verifyValues(BatchInbox.fetcher()) 25 | verifyValues(BatchInbox.fetcher(forUserIdentifier: "foobar", authenticationKey: "12345")!) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Sources/batchTests/Modules/Profile/profileCenterTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BatchTests 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | import Batch.Batch_Private 8 | import XCTest 9 | 10 | @testable import Batch 11 | 12 | final class profileCenterTests: XCTestCase { 13 | let eventTracker = MockEventTracker() 14 | 15 | override func setUp() { 16 | super.setUp() 17 | let _ = eventTracker.registerOverlay() 18 | } 19 | 20 | override func tearDown() { 21 | eventTracker.reset() 22 | } 23 | 24 | func testApplyEditor() throws { 25 | let editor = BatchProfile.editor() 26 | try? editor.set(attribute: true, forKey: "booleanAttribute") 27 | editor.save() 28 | XCTAssertNotNil(eventTracker.findEvent(name: .profileDataChanged, parameters: nil)) 29 | } 30 | 31 | func testEmptyApplyEditor() throws { 32 | let editor = BatchProfile.editor() 33 | editor.save() 34 | XCTAssertNil(eventTracker.findEvent(name: .profileDataChanged, parameters: nil)) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Sources/Batch/BASecureDate.h: -------------------------------------------------------------------------------- 1 | // 2 | // BASecureDate.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BASecureDate : NSObject 12 | 13 | /*! 14 | @method instance 15 | @abstract Instance method. 16 | @return BASecureDate singleton. 17 | */ 18 | + (BASecureDate *)instance __attribute__((warn_unused_result)); 19 | 20 | /*! 21 | @method updateServerDate: 22 | @abstract Update the secure date system with the server date. 23 | @param timestamp : Server timestamp in milliseconds. 24 | */ 25 | - (void)updateServerDate:(NSNumber *)timestamp; 26 | 27 | /*! 28 | @method date 29 | @abstract The computed secure date. 30 | @return Secure NSDate or nil if no server hit succed. 31 | */ 32 | - (NSDate *)date __attribute__((warn_unused_result)); 33 | 34 | /*! 35 | @method formattedString 36 | @abstract Formated string date. 37 | @return Date string representation. 38 | */ 39 | - (NSString *)formattedString __attribute__((warn_unused_result)); 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Messaging/CEP/InApp/Models/InAppCustomStyle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | extension InAppViewController { 8 | /// Represents a custom style to handle overleap safe area as MEP 9 | /// Should only be used in ``InAppViewController`` 10 | struct InAppCustomStyle: InAppBorderable & InAppRoundableCorners { 11 | let borderWidth: CGFloat? 12 | let borderColor: UIColor? 13 | let radius: [CGFloat] 14 | 15 | static func empty() -> Self { 16 | Self( 17 | borderWidth: nil, 18 | borderColor: nil, 19 | radius: [] 20 | ) 21 | } 22 | } 23 | } 24 | 25 | extension InAppViewController.Configuration { 26 | func customStyle() -> InAppViewController.InAppCustomStyle { 27 | return InAppViewController.InAppCustomStyle( 28 | borderWidth: style.borderWidth, 29 | borderColor: style.borderColor, 30 | radius: style.radius 31 | ) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Push/BAPushPayload.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAPushMessage.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /*! 12 | @class BAPushMessage 13 | @abstract Push message formated. 14 | @discussion Parse the message user info. 15 | */ 16 | @interface BAPushPayload : NSObject 17 | 18 | /*! 19 | @property rawDeeplink 20 | @abstract Deeplink string 21 | */ 22 | @property (strong, readonly) NSString *rawDeeplink; 23 | 24 | @property (nonatomic, readonly) BOOL openDeeplinksInApp; 25 | 26 | /*! 27 | @property data 28 | @abstract Data, can contain the campaign identifier and the scheme (optional, can be nil). 29 | */ 30 | @property (strong, readonly) NSDictionary *data; 31 | 32 | /*! 33 | @property openEventData 34 | @abstract Data to track when tracking an open event 35 | */ 36 | @property (strong, readonly) NSDictionary *openEventData; 37 | 38 | - (instancetype)initWithUserInfo:(NSDictionary *)info; 39 | 40 | - (BOOL)requiresReadReceipt; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /Sources/Batch/Webservices/Query Services Implementations/Response Models/BAWSResponseAttributes.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAWSResponseAttributes.h 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2014 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /*! 12 | @class BAWSResponseAttributes 13 | @abstract Response of a BAWebserviceQueryAttributes. 14 | @discussion Build and serialize the response to the query. 15 | */ 16 | @interface BAWSResponseAttributes : BAWSResponse 17 | 18 | /*! 19 | @method init 20 | @warning Never call this method. 21 | */ 22 | - (instancetype)init NS_UNAVAILABLE; 23 | 24 | /*! 25 | @property transactionID 26 | @abstract Returned transaction ID. 27 | */ 28 | @property (readonly) NSString *transactionID; 29 | 30 | /*! 31 | @property version 32 | @abstract Returned data version. 33 | */ 34 | @property (readonly) NSNumber *version; 35 | 36 | /*! 37 | @property projectKey 38 | @abstract ProjectKey attached the application 39 | */ 40 | @property (readonly) NSString *projectKey; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /Sources/Batch/Kernel/Helpers/BARandom.m: -------------------------------------------------------------------------------- 1 | // 2 | // BARandom.m 3 | // Batch 4 | // 5 | // https://batch.com 6 | // Copyright (c) 2016 Batch SDK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @implementation BARandom 12 | 13 | // Generate a random [0-9][a-z][A-Z] string. 14 | + (NSString *)randomAlphanumericStringWithLength:(int)length { 15 | static NSString *letters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 16 | 17 | NSMutableString *randomString = [NSMutableString stringWithCapacity:length]; 18 | 19 | for (int i = 0; i < length; i++) { 20 | [randomString appendFormat:@"%C", [letters characterAtIndex:arc4random() % [letters length]]]; 21 | } 22 | 23 | return randomString; 24 | } 25 | 26 | // Generate a random identifier using CFUUIDCreateString() method. 27 | + (NSString *)generateUUID { 28 | CFUUIDRef theUUID = CFUUIDCreate(NULL); 29 | NSString *newID = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, theUUID); 30 | CFRelease(theUUID); 31 | 32 | return newID; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Sources/Batch/Modules/Domain/BADomainManagerProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Batch 3 | // 4 | // Copyright © Batch.com. All rights reserved. 5 | // 6 | 7 | @objc 8 | public protocol BADomainManagerProtocol { 9 | /// Update current domain if needed 10 | func updateDomainIfNeeded() 11 | 12 | /// Updates the date of the last check performed on the domain. 13 | func updateLastCheckDomainDate() 14 | 15 | /// Reset current domain to the orgininal one 16 | func resetDomainToOriginal() 17 | 18 | /// Resets the error count if needed, for instance if a success api call was done on the current domain. 19 | func resetErrorCountIfNeeded() 20 | 21 | /// Determines if the original domain can be checked for availability. 22 | func canCheckOriginalDomainAvalaibility() -> Bool 23 | 24 | /// Returns the URL associated with a specific service. 25 | /// The `overrideWithOriginal` parameter determines whether the URL should be based on the original domain or the current domain. 26 | func url(for service: BADomainService, overrideWithOriginal: Bool) -> String 27 | } 28 | --------------------------------------------------------------------------------