Skip to content

Commit

Permalink
add ATT command (#465)
Browse files Browse the repository at this point in the history
* add ATT command

* fix project file

* add test

* update version

* fix CHANGELOG

---------

Co-authored-by: Sojiro Nishimura <[email protected]>
  • Loading branch information
SojiroNishimura and Sojiro Nishimura authored Aug 26, 2024
1 parent 9d2c66a commit 7703139
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .spm-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.17.0
2.18.0
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

| モジュール名 | Description | 最新のバージョン |
| :-- | :-- | :-- |
| KarteCore | イベントトラッキング機能を提供します。 | 2.29.0 |
| KarteCore | イベントトラッキング機能を提供します。 | 2.30.0 |
| KarteInAppMessaging | アプリ内メッセージ機能を提供します。 | 2.18.0 |
| KarteRemoteNotification | プッシュ通知の受信および効果測定機能を提供します。 | 2.11.0 |
| KarteVariables | 設定値配信機能を提供します。 | 2.10.0 |
Expand All @@ -11,6 +11,12 @@
| KarteUtilities | KarteCore モジュール等が利用するUtility機能を提供します。通常直接参照する必要はありません。 | 3.12.0 |
| KarteNotificationServiceExtension | リッチプッシュ通知機能を提供します。 | 1.2.0 |

# Releases - xxxx.xx.xx

### Core 2.30.0
** 🎉 FEATURE**
- Native機能呼び出しにATT許諾ダイアログ表示を追加しました。

# Releases - 2024.08.26
## Version 2.17.0

Expand Down
12 changes: 10 additions & 2 deletions Karte.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@
AF0A5F2F29546BB000209D4E /* Logger+Tag.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF0A5F2E29546BB000209D4E /* Logger+Tag.swift */; };
AF0A5F31295475B300209D4E /* KarteInbox.m in Sources */ = {isa = PBXBuildFile; fileRef = AF0A5F30295475B300209D4E /* KarteInbox.m */; };
AF0A5F352959986F00209D4E /* InboxLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = AF0A5F342959986F00209D4E /* InboxLoader.m */; };
AF38FD9E2C7C7313009C1C20 /* RequestATTCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF38FD9D2C7C7313009C1C20 /* RequestATTCommand.swift */; };
AF38FDA02C7C8108009C1C20 /* RequestATTCommandSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF38FD9F2C7C8108009C1C20 /* RequestATTCommandSpec.swift */; };
AF49FAA1296ED953005A7575 /* CallerSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF49FAA0296ED953005A7575 /* CallerSpec.swift */; };
AF5EDEB329C1C49000D05825 /* OpenMessagesRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF5EDEB229C1C49000D05825 /* OpenMessagesRequestSpec.swift */; };
AF5EDEB529C1C5A600D05825 /* OpenMessagesRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF5EDEB429C1C5A600D05825 /* OpenMessagesRequest.swift */; };
Expand Down Expand Up @@ -1031,6 +1033,8 @@
AF0A5F2E29546BB000209D4E /* Logger+Tag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Logger+Tag.swift"; sourceTree = "<group>"; };
AF0A5F30295475B300209D4E /* KarteInbox.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KarteInbox.m; sourceTree = "<group>"; };
AF0A5F342959986F00209D4E /* InboxLoader.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InboxLoader.m; sourceTree = "<group>"; };
AF38FD9D2C7C7313009C1C20 /* RequestATTCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RequestATTCommand.swift; sourceTree = "<group>"; };
AF38FD9F2C7C8108009C1C20 /* RequestATTCommandSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestATTCommandSpec.swift; sourceTree = "<group>"; };
AF49FAA0296ED953005A7575 /* CallerSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallerSpec.swift; sourceTree = "<group>"; };
AF5EDEB229C1C49000D05825 /* OpenMessagesRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenMessagesRequestSpec.swift; sourceTree = "<group>"; };
AF5EDEB429C1C5A600D05825 /* OpenMessagesRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenMessagesRequest.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2255,6 +2259,7 @@
0CE33A0523F40C2200E2EB98 /* UserSyncParameterSpec.swift */,
681E83982483B54800A95083 /* RequestReviewCommandSpec.swift */,
681E839A2483B5C800A95083 /* OpenSettingsCommandSpec.swift */,
AF38FD9F2C7C8108009C1C20 /* RequestATTCommandSpec.swift */,
);
path = Core;
sourceTree = "<group>";
Expand Down Expand Up @@ -2383,6 +2388,7 @@
681E83942482A90E00A95083 /* OpenSettingsCommand.swift */,
680DB3C72480F74E00AE6800 /* Command.swift */,
681E838C248246B700A95083 /* RequestReviewCommand.swift */,
AF38FD9D2C7C7313009C1C20 /* RequestATTCommand.swift */,
681E838E2482510200A95083 /* CommandHandler.swift */,
681E8390248252EE00A95083 /* CommandHandlerLoader.m */,
);
Expand Down Expand Up @@ -3112,6 +3118,7 @@
777D605D274267FC00339D7E /* InvalidEventFieldNameFilterRule.swift in Sources */,
0C69D40F24EB9DB200D75893 /* InitializationEventFilterRule.swift in Sources */,
0C0822FB24EA615C0038EBDA /* CommandBundlerApplicationStateProvider.swift in Sources */,
AF38FD9E2C7C7313009C1C20 /* RequestATTCommand.swift in Sources */,
0C83928F2406C6AA0014C2BF /* InstallationStatus.swift in Sources */,
0C69D3FC24EB9D9D00D75893 /* TrackClientState.swift in Sources */,
0C8392B72406C7010014C2BF /* Module.swift in Sources */,
Expand Down Expand Up @@ -3380,6 +3387,7 @@
0CE79327238653AD00F0D932 /* SpecConfiguration.swift in Sources */,
0CC648B8238CCFC3009EB5DF /* StubBuilder.swift in Sources */,
0CCFA7B524A5814100E0F184 /* FCMTokenRegistrarSpec.swift in Sources */,
AF38FDA02C7C8108009C1C20 /* RequestATTCommandSpec.swift in Sources */,
0C839316240838050014C2BF /* ActionAppropriateViewDetectorSpec.swift in Sources */,
363F25F12582A1EB007E6E4B /* DefinitionsRequestSpec.swift in Sources */,
0C520BCC2990995000480B77 /* JSONConvertibleSpec.swift in Sources */,
Expand Down Expand Up @@ -3852,7 +3860,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.29.0;
MARKETING_VERSION = 2.30.0;
PRODUCT_BUNDLE_IDENTIFIER = io.karte.KarteCore;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -3887,7 +3895,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.29.0;
MARKETING_VERSION = 2.30.0;
PRODUCT_BUNDLE_IDENTIFIER = io.karte.KarteCore;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down
2 changes: 1 addition & 1 deletion KarteCore.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'KarteCore'
s.version = '2.29.0'
s.version = '2.30.0'
s.summary = 'KARTE Core SDK'
s.homepage = 'https://karte.io'
s.author = { 'PLAID' => '[email protected]' }
Expand Down
3 changes: 2 additions & 1 deletion KarteCore/Core/Command/CommandHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ extension CommandHandler: DeepLinkModule {
public func handle(app: UIApplication, open url: URL) -> Bool {
let commands: [Command] = [
RequestReviewCommand(),
OpenSettingsCommand()
OpenSettingsCommand(),
RequestATTCommand()
]
return commands.map { $0.run(url: url) }.contains(true)
}
Expand Down
49 changes: 49 additions & 0 deletions KarteCore/Core/Command/RequestATTCommand.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// Copyright 2024 PLAID, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import AppTrackingTransparency

internal struct RequestATTCommand: Command {
func validate(_ url: URL) -> Bool {
url.host == "request-att"
}

func execute() {
if #available(iOS 14.5, *) {
guard ATTrackingManager.trackingAuthorizationStatus == .notDetermined else {
Logger.warn(tag: .core, message: "ATT is already determined, status = \(ATTrackingManager.trackingAuthorizationStatus)")
return
}

ATTrackingManager.requestTrackingAuthorization { status in
switch status {
case .authorized:
Logger.info(tag: .core, message: "ATT status is authorized")
case .denied:
Logger.info(tag: .core, message: "ATT status is denied")
case .notDetermined:
Logger.info(tag: .core, message: "ATT status is notDetermined")
case .restricted:
Logger.info(tag: .core, message: "ATT status is restricted")
@unknown default:
Logger.warn(tag: .core, message: "ATT status is unknown: \(status)")
}
}
} else {
Logger.warn(tag: .core, message: "iOS version must be over 14.5, ATT is not available")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// Copyright 2024 PLAID, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Quick
import Nimble
@testable import KarteCore

class RequestATTCommandSpec: QuickSpec {
override func spec() {
describe("its run") {
context("when invalid value passed") {
let examples = [
"test:",
"krt:",
"krt://request-att",
"aaa-karte-sdk://request-att",
"krt-hSZM://request-att",
"krt-hSZMcVyjwg6Y7pdYMa4YPqmyQ77EpALw://request-review",
]
examples.forEach { (input) in
context("\(input)") {
it("returns false") {
let c = RequestATTCommand()
let u = URL(string: input)!
expect(c.run(url: u)).to(beFalse())
}
}
}
}

context("when valid value passed") {
let examples = [
"krt-hSZMcVyjwg6Y7pdYMa4YPqmyQ77EpALw://request-att",
"krt-HRTwj9QEZGJrTaTkADrtdxFTyuXUJVMh://request-att"
]
examples.forEach { (input) in
context("\(input)") {
it("returns true") {
let c = RequestATTCommand()
let u = URL(string: input)!
expect(c.run(url: u)).to(beTrue())
}
}
}
}
}
}
}

0 comments on commit 7703139

Please sign in to comment.