From b05d2b71fcd95d47eccf2b8fae259749d8a8d860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20=C4=8Eurech?= Date: Fri, 17 Jan 2025 10:45:53 +0100 Subject: [PATCH 1/2] docs: Activation data sharing in one place Fix #628 --- docs/PowerAuth-SDK-for-iOS.md | 78 ++++++++++++++++++++++++++++++++--- 1 file changed, 72 insertions(+), 6 deletions(-) diff --git a/docs/PowerAuth-SDK-for-iOS.md b/docs/PowerAuth-SDK-for-iOS.md index 5fd7996c..507f6f4d 100644 --- a/docs/PowerAuth-SDK-for-iOS.md +++ b/docs/PowerAuth-SDK-for-iOS.md @@ -1693,17 +1693,62 @@ You can remove EEK from an existing activation if the key is no longer required. ## Share Activation Data -This chapter explains how to share the `PowerAuthSDK` activation state between multiple applications from the same vendor, or between application and its extensions. Before you start, you should read [Prepare Data Sharing](PowerAuth-SDK-for-iOS-Extensions.md#prepare-data-sharing) chapter from PowerAuth SDK for iOS Extensions to configure *Keychain Sharing* and *App Groups* in your Xcode project. +This chapter explains how to share the `PowerAuthSDK` activation state between application and its extensions, or between multiple applications from the same vendor. This feature is not supported on the macOS Catalyst platform. +### Prepare Activation Data Sharing + +The App Extension normally doesn't have access to data created by the main application, so the first step is to set up data sharing for your project. + +#### Keychain Sharing + +iOS SDK stores its most sensitive data into the iOS keychain, so you need to configure the keychain sharing first. If you're not familiar with keychain sharing, then don't worry about that, the keychain is shared only between the vendor's applications. So the sensitive information is not exposed to 3rd party applications. + +1. Select your application project in the **Project Navigator** to navigate to the target configuration window and select the applications's target under the **TARGETS** heading in the sidebar. +2. Now select **Signing & Capabilities** tab and click **+ Capability** button. +3. Find and add **Keychain Sharing** capability. +4. Click "+" in just created **Keychain Sharing** capability and Xcode will predefine first **Keychain Group** to your application's bundle name. Let's call this value as `KEYCHAIN_GROUP_NAME` + + +The predefined group is usually beneficial because iOS is by default using that group for storing all keychain entries created in the application. So, If your application is already using PowerAuth and you're going to just add extension support, then this is the most simple way to set up a keychain sharing. + + +Now you have to do a similar setup for your application's extension: + +5. Select your application project in the **Project Navigator** to navigate to the target configuration window and select the extensions's target under the **TARGETS** heading in the sidebar. +6. Select **Signing & Capabilities** tab and click **+ Capability** button. +7. Find and add **Keychain Sharing** capability. +8. Click "+" in just created **Keychain Sharing** capability and add the same `KEYCHAIN_GROUP_NAME` as you did for the application's target. +9. (optional) Repeat steps 4 to 6 for all other extensions which supposed to use shared activation data. + +Now you need to know your **Team ID** (the unique identifier assigned to your team by Apple). Unfortunately, the identifier is not simply visible in Xcode, so you'll have to log in to Apple's [development portal](http://developer.apple.com/account) and look for that identifier on your membership details page. + +If you know the Team ID, then the final `KEYCHAIN_GROUP_IDENTIFIER` constant is composed as `TEAM_ID.KEYCHAIN_GROUP_NAME`. So, it should look like: `KTT00000MR.com.powerauth.demo.App`. + +#### App Groups + +The PowerAuth SDK for iOS is using one boolean flag stored in the `UserDefaults` facility, to determine whether the application has been reinstalled. Unfortunately, the `UserDefaults.standard` created by the application cannot be shared with the app extension, so you have to create a new application group to share that data. + +1. Select your application project in the **Project Navigator** to navigate to the target configuration window and select the applications's target under the **TARGETS** heading in the sidebar. +2. Now select **Signing & Capabilities** tab and click **+ Capability** button. +3. Find and add **App Groups** capability. +3. Click "+" in just created **App Groups** capability add a group with the desired identifier and turn this particular group ON (e.g. make sure that the checkmark close to the group's name is selected). Let's call this value `APP_GROUP_IDENTIFIER`. If the group already exists, then just click the checkmark to turn it ON. +4. Now switch to the application's extension target, select the **Capabilities** tab, and also expand the **App Groups** section. +5. Turn "ON" **App Groups** for extension and add an app group with the same name as you did in step 3. + +You can optionally check a troubleshooting section if you need to [migrate the keychain initialization flag](#userdefaults-migration) from standard user defaults to a shared one. + ### Configure Activation Data Sharing To share the activation's state just assign an instance of the `PowerAuthSharingConfiguration` object into `PowerAuthConfiguration`: ```swift +// Keychain sharing and App Group constants +let keychainSharing = "KTT00000MR.com.powerauth.demo.App" // KEYCHAIN_GROUP_IDENTIFIER constant +let appGroup = "group.your.app.group" // APP_GROUP_IDENTIFIER constant // Prepare the configuration let configuration = PowerAuthConfiguration( instanceId: Bundle.main.bundleIdentifier!, @@ -1711,9 +1756,9 @@ let configuration = PowerAuthConfiguration( configuration: "ARDDj6EB6iAUtNm...KKEcBxbnH9bMk8Ju3K1wmjbA==") // Assign sharing configuration configuration.sharingConfiguration = PowerAuthSharingConfiguration( - appGroup: "group.your.app.group", + appGroup: appGroup, appIdentifier: "com.powerauth.demo.App", - keychainAccessGroup: "KTT00000MR.com.powerauth.demo.App") + keychainAccessGroup: keychainSharing) // Create a PowerAuthSDK instance let powerAuthSDK = PowerAuthSDK(configuration) @@ -1722,11 +1767,10 @@ let powerAuthSDK = PowerAuthSDK(configuration) The `PowerAuthSharingConfiguration` object contains the following properties: - `appGroup` is the name of the app group shared between your applications. Be aware, that the length of app group encoded in UTF-8, should not exceed 26 characters. See [troubleshooting](#length-of-application-group) section for more details. -- `appIdentifier` is an identifier unique across your all applications that are supposed to use the shared activation data. You can use your applications' bundle identifiers or any other identifier that can be then processed in all your applications. Due to technical limitations, the length of the identifier must not exceed 127 bytes, if represented in UTF-8. +- `appIdentifier` is an identifier unique across your all applications or extensions that are supposed to use the shared activation data. You can use your applications' bundle identifiers or any other identifier that can be then processed in all your applications. Due to technical limitations, the length of the identifier must not exceed 127 bytes, if represented in UTF-8. - `keychainAccessGroup` is an access group for keychain sharing. -Unlike the regular configuration the `instanceId` value in `PowerAuthConfiguration` should not be based on the application's bundle identifier. This is because all your applications must use the same identifier, so it's recommended to use some predefined constant string. - +Unlike the regular configuration the `instanceId` value in `PowerAuthConfiguration` should not be derived on the application's bundle identifier. This is because all applications and extensions that share PowerAuth data must use the same identifier. To ensure consistency, use a predefined constant string or an identifier based on the first application that integrated PowerAuth. This guarantees that all related components can access the same PowerAuth instance without conflicts. ### External pending operations @@ -2158,3 +2202,25 @@ The total length is limited to 31 characters, but the shared memory object name ``` You can extend the length of the application group slightly by providing your own `sharedMemoryIdentifier` in the `PowerAuthSharingConfiguration`. In theory, this allows you to use an app group name of up to 29 characters, leaving 1 character for the shared memory identifier. However, this is generally not recommended. A custom identifier should only be used if your application already employs shared memory and the SDK’s generated identifier conflicts with your existing shared memory objects. + +### UserDefaults Migration + +If your previous version of the application did not use shared data between the application and the extension, then you probably need to migrate the keychain status flag from `UserDefaults.standard` to a shared one. We recommend performing this migration at the main application's startup code and **BEFORE** the `PowerAuthSDK` object is configured and used: + +```swift +private func migrateUserDefaults(appGroup: String) { + guard let shared = UserDefaults(suiteName: appGroup) else { + fatalError("AppGroup is not configured properly") + } + if shared.bool(forKey: PowerAuthKeychain_Initialized) { + return // migration is not required + } + let standard = UserDefaults.standard + if standard.bool(forKey: PowerAuthKeychain_Initialized) { + standard.removeObject(forKey: PowerAuthKeychain_Initialized) + standard.synchronize() + shared.set(true, forKey: PowerAuthKeychain_Initialized) + shared.synchronize() + } +} +``` From c715c298e70e1956cedc4368161fe3c43eb8a2e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20=C4=8Eurech?= Date: Fri, 17 Jan 2025 10:55:03 +0100 Subject: [PATCH 2/2] docs: Remove iOS App Extensions documentation Fix #632 --- README.md | 1 - docs/Migration-from-1.9-to-1.10.md | 7 +- docs/PowerAuth-SDK-for-iOS-Extensions.md | 283 ----------------------- docs/PowerAuth-SDK-for-iOS.md | 23 +- docs/PowerAuth-SDK-for-watchOS.md | 23 -- docs/Readme.md | 1 - docs/_Sidebar.md | 1 - 7 files changed, 4 insertions(+), 335 deletions(-) delete mode 100644 docs/PowerAuth-SDK-for-iOS-Extensions.md diff --git a/README.md b/README.md index fd7f71bd..787b4a9d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ In order to connect to the [PowerAuth](https://www.wultra.com/product/powerauth- ## Integration Tutorials - [PowerAuth SDK for iOS and tvOS Apps](./docs/PowerAuth-SDK-for-iOS.md) -- [PowerAuth SDK for iOS and tvOS Extensions](./docs/PowerAuth-SDK-for-iOS-Extensions.md) - [PowerAuth SDK for watchOS](./docs/PowerAuth-SDK-for-watchOS.md) - [PowerAuth SDK for Android Apps](./docs/PowerAuth-SDK-for-Android.md) diff --git a/docs/Migration-from-1.9-to-1.10.md b/docs/Migration-from-1.9-to-1.10.md index 38db733e..b33cecf4 100644 --- a/docs/Migration-from-1.9-to-1.10.md +++ b/docs/Migration-from-1.9-to-1.10.md @@ -66,14 +66,13 @@ PowerAuth Mobile SDK in version `1.10.0` provides the following improvements: ## iOS & tvOS App Extensions -- Removed all interfaces deprecated in release `1.9.x` +- The `PowerAuth2ForExtensions` library is now deprecated and no longer supported and maintained. You can use full feature PowerAuth mobile SDK as a replacement in your app extension. ## Known Bugs -The PowerAuth SDKs for iOS and tvOS App Extensions, as well as for watchOS, do not use time synchronized with the server for token-based authentication. To avoid any compatibility issues with the server, the authentication headers generated in your App Extension or on watchOS still use the older protocol version 3.1. This issue will be fixed in a future SDK update. +The PowerAuth SDKs for watchOS, do not use time synchronized with the server for token-based authentication. To avoid any compatibility issues with the server, the authentication headers generated in your App Extension or on watchOS still use the older protocol version 3.1. This issue will be fixed in a future SDK update. You can watch the following related issues: - [wultra/powerauth-mobile-sdk#551](https://github.com/wultra/powerauth-mobile-sdk/issues/551) -- [wultra/powerauth-mobile-watch-sdk#7](https://github.com/wultra/powerauth-mobile-watch-sdk/issues/7) -- [wultra/powerauth-mobile-extensions-sdk#7](https://github.com/wultra/powerauth-mobile-extensions-sdk/issues/7) \ No newline at end of file +- [wultra/powerauth-mobile-watch-sdk#7](https://github.com/wultra/powerauth-mobile-watch-sdk/issues/7) \ No newline at end of file diff --git a/docs/PowerAuth-SDK-for-iOS-Extensions.md b/docs/PowerAuth-SDK-for-iOS-Extensions.md deleted file mode 100644 index 4c497b76..00000000 --- a/docs/PowerAuth-SDK-for-iOS-Extensions.md +++ /dev/null @@ -1,283 +0,0 @@ -# PowerAuth Mobile SDK for iOS and tvOS Extensions - - -## Table of Contents - -- [Introduction](#introduction) -- [Installation](#installation) - - [CocoaPods Installation](#cocoapods) - - [Manual Installation](#manual) -- [SDK Configuration](#configuration) - - [Prepare Data Sharing](#prepare-data-sharing) - - [Configure PowerAuth for Extension](#configure-powerauth-for-extension) -- [Getting Device Activation Status](#getting-device-activation-status) -- [Token-Based Authentication](#token-based-authentication) - - [Getting token](#getting-token) - - [Generating Authorization Header](#generating-authorization-header) - - [Removing Token Locally](#removing-token-locally) - - [Removing Token From the Server](#removing-tokenf-from-the-server) -- [Common SDK Tasks](#common-sdk-tasks) -- [Troubleshooting](#troubleshooting) - -Related documents: - -- [PowerAuth SDK for iOS](./PowerAuth-SDK-for-iOS.md) -- [PowerAuth SDK for watchOS](./PowerAuth-SDK-for-watchOS.md) - - -## Introduction - -The PowerAuth Mobile SDK Extensions library is a lightweight counterpart to the full-featured PowerAuth Mobile SDK, providing limited functionality, such as: - -- Retrieving information about activation presence -- Obtaining authentication tokens - -If you need to perform more operations in your extension, such as calculating [PowerAuth symmetric signatures](./PowerAuth-SDK-for-iOS.md#symmetric-multi-factor-signature), you can use the full-featured [PowerAuth mobile SDK](./PowerAuth-SDK-for-iOS.md). This can be achieved by configuring [activation data sharing](./PowerAuth-SDK-for-iOS.md#share-activation-data) in both your application and the extension. - -## Installation - -This chapter describes how to get PowerAuth SDK for iOS and tvOS Extensions up and running in your app. In the current version, you can choose between CocoaPods and manual library integration. Both types of installation will lead to your app extension linked with a dynamic library, provided by the `PowerAuth2ForExtensions.[xc]framework`. - -To distinguish between SDKs, the following short terms will be used in this document: - -- **iOS SDK**, as short term for *PowerAuth SDK for iOS and tvOS* -- **Extensions SDK** as short term for *PowerAuth SDK for iOS and tvOS Extensions* - -### CocoaPods - -[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command: -```bash -$ gem install cocoapods -``` - -To integrate the PowerAuth library into your Xcode project using CocoaPods, specify it in your `Podfile`: -```ruby -platform :ios, '11.0' - -target 'YourAppTarget' do - pod 'PowerAuth2' -end - -target 'YourExtensionTarget' do - pod 'PowerAuth2ForExtensions' -end -``` - -Then, run the following command: -```bash -$ pod install -``` - -### Manual - -If you prefer not to use CocoaPods as a dependency manager, you can integrate Extensions SDK into your project manually as a git [submodule](http://git-scm.com/docs/git-submodule). - -#### Git Submodules - -The integration process is quite similar to the integration of our iOS library: - -1. Open up the Terminal.app and go to your top-level project directory and add the library as a submodule: - ```sh - $ git submodule add https://github.com/wultra/powerauth-mobile-sdk.git PowerAuthLib - $ git submodule update --init --recursive - ``` - The first command will clone PowerAuth SDK into the `PowerAuthLib` folder and the second, will update all nested submodules. We're expecting that you already did this when you integrated PowerAuth into your application. - -2. Open the new `PowerAuthLib` folder, and go to the `proj-xcode` sub-folder -3. Drag the `PowerAuthExtensionSdk.xcodeproj` project file into **Project Navigator** of your application's Xcode project. It should appear nested underneath your application's blue project icon. -4. Select your application project in the Project Navigator to navigate to the target configuration window and select the extension's target under the **TARGETS** heading in the sidebar. -5. Now select **Build Phases** tab and expand **Target Dependencies** section. Click on the "Plus Sign" and choose **"PowerAuth2ForExtensions"** framework from the **"PowerAuthExtensionSdk"** project. -6. Next, in the same **Build Phases** tab expand **Link With Libraries** section. Click on the "Plus Sign" and choose **"PowerAuth2ForExtensions.framework"** from the **"PowerAuthExtensionSdk"** project. - - - -## Configuration - -The Extensions SDK shares several source codes and configuration principles with the main iOS SDK. So, you can prepare the same set of constants as you're already using in your IOS application. The SDK provides just a limited functionality for app extension (for example, you cannot create an activation or calculate a full PowerAuth signature from an extension) and to do that it requires access to an activation data, created in the main application. - -### Prepare Data Sharing - -The App Extension normally doesn't have access to data created by the main application, so the first step is to set up data sharing for your project. - -#### Keychain Sharing - -iOS SDK stores its most sensitive data into the iOS keychain, so you need to configure the keychain sharing first. If you're not familiar with keychain sharing, then don't worry about that, the keychain is shared only between the vendor's applications. So the sensitive information is not exposed to 3rd party applications. - -1. Select your application project in the **Project Navigator** to navigate to the target configuration window and select the applications's target under the **TARGETS** heading in the sidebar. -2. Now select **Signing & Capabilities** tab and click **+ Capability** button. -3. Find and add **Keychain Sharing** capability. -4. Click "+" in just created **Keychain Sharing** capability and Xcode will predefine first **Keychain Group** to your application's bundle name. Let's call this value as `KEYCHAIN_GROUP_NAME` - - -The predefined group is usually beneficial because iOS is by default using that group for storing all keychain entries created in the application. So, If your application is already using PowerAuth and you're going to just add extension support, then this is the most simple way to set up a keychain sharing. - - -Now you have to do a similar setup for your application's extension: - -5. Select your application project in the **Project Navigator** to navigate to the target configuration window and select the extensions's target under the **TARGETS** heading in the sidebar. -6. Select **Signing & Capabilities** tab and click **+ Capability** button. -7. Find and add **Keychain Sharing** capability. -8. Click "+" in just created **Keychain Sharing** capability and add the same `KEYCHAIN_GROUP_NAME` as you did for the application's target. -9. (optional) Repeat steps 4 to 6 for all other extensions which supposed to use Extensions SDK. - -Now you need to know your **Team ID** (the unique identifier assigned to your team by Apple). Unfortunately, the identifier is not simply visible in Xcode, so you'll have to log in to Apple's [development portal](http://developer.apple.com) and look for that identifier on your membership details page. - -If you know the Team ID, then the final `KEYCHAIN_GROUP_IDENTIFIER` constant is composed as `TEAM_ID.KEYCHAIN_GROUP_NAME`. So, it should look like: `KTT00000MR.com.powerauth.demo.App`. - -#### App Groups - -The PowerAuth SDK for iOS is using one boolean flag stored in the `UserDefaults` facility, to determine whether the application has been reinstalled. Unfortunately, the `UserDefaults.standard` created by the application cannot be shared with the app extension, so you have to create a new application group to share that data. - -1. Select your application project in the **Project Navigator** to navigate to the target configuration window and select the applications's target under the **TARGETS** heading in the sidebar. -2. Now select **Signing & Capabilities** tab and click **+ Capability** button. -3. Find and add **App Groups** capability. -3. Click "+" in just created **App Groups** capability add a group with the desired identifier and turn this particular group ON (e.g. make sure that the checkmark close to the group's name is selected). Let's call this value `APP_GROUP_IDENTIFIER`. If the group already exists, then just click the checkmark to turn it ON. -4. Now switch to the application's extension target, select the **Capabilities** tab, and also expand the **App Groups** section. -5. Turn "ON" **App Groups** for extension and add an app group with the same name as you did in step 3. - -You can optionally check a troubleshooting section if you need to [migrate the keychain initialization flag](#userdefaults-migration) from standard user defaults to a shared one. - - -While all previous steps are optional, they are highly recommended. If the keychain is properly shared, then the Extension SDK can determine the status of the PowerAuth activation just from the content of keychain data. But still, this has a drawback, because the keychain data persists between the application's reinstallation. As you can see, in a couple of rare usage scenarios the extension may get inaccurate information about the activation. - - -### Configure PowerAuth for Extension - -If the data sharing is right, then the configuration of PowerAuth SDK for iOS Extension is pretty straightforward: - -```swift -import PowerAuth2ForExtensions - -class TodayViewController: UIViewController, NCWidgetProviding { - - // Lazy initialized variable - private var powerAuthExt: PowerAuthExtensionSDK = { - return TodayViewController.setupPowerAuth() - }() - - private static func setupPowerAuth() -> PowerAuthExtensionSDK { - let config = PowerAuthConfiguration( - instanceId: Bundle.main.bundleIdentifier!, - baseEndpointUrl: "https://localhost:8080/demo-server", - configuration: "ARDDj6EB6iAUtNm...KKEcBxbnH9bMk8Ju3K1wmjbA==") - - let keychainConfig = PowerAuthKeychainConfiguration.sharedInstance() - keychainConfig.keychainAttribute_AccessGroup = "KEYCHAIN_GROUP_IDENTIFIER" - keychainConfig.keychainAttribute_UserDefaultsSuiteName = "APP_GROUP_IDENTIFIER" - - return PowerAuthExtensionSDK(configuration: config, keychainConfiguration: keychainConfig)! - } - - // ... the rest of the controller's code ... -} -``` - - -**IMPORTANT:** The configuration used above must match the configuration used in the application otherwise your extension will never get a proper activation status. - - -The Extensions SDK doesn't provide a shared instance for the `PowerAuthExtensionSDK` class and therefore you have to manage that instance on your own. The example above shows the beginning of a simple controller implementing an extension for the Today Widget. For all other code examples, we're going to use `this.powerAuthExt` as a properly initialized instance of the `PowerAuthExtensionSDK` object. - - -## Getting Device Activation Status - -Unlike the iOS SDK, the Extension SDK provides only limited information about activation status. You can check only whether there's locally stored activation or not: - -```swift -if this.powerAuthExt.hasValidActivation() { - // main application has a valid activation locally stored -} -``` - - -## Token-Based Authentication - - -**WARNING:** Before you start using access tokens, please visit our [wiki page for powerauth-crypto](https://github.com/wultra/powerauth-crypto/blob/develop/docs/MAC-Token-Based-Authentication.md) for more information about this feature. You can also check the documentation about tokens available in [PowerAuth SDK for iOS](./PowerAuth-SDK-for-iOS.md#token-based-authentication). - - - -### Getting Token - -To get an access token, you can use the following code: - -```swift -if let token = this.powerAuthExt.tokenStore.localToken(withName: "MyToken") { - // you have a token that can generate authorization headers -} -``` - -Note that the token store also provides the `requestAccessToken()` method, but that always returns the `PowerAuthErrorCode.invalidToken` error. Unlike the iOS SDK API, you cannot get a token from the server from the app extension. Only the main application can do that and once the token is available, then it's also available for the app extension. Check PowerAuth SDK for iOS [documentation for more details](./PowerAuth-SDK-for-iOS.md#getting-token). - -### Generating Authorization Header - -Once you have a `PowerAuthToken` object, use the following code to generate an authorization header: - -```swift -if let header = token.generateHeader() { - let httpHeader = [ header.key : header.value ] - // now you can attach that httpHeader to your HTTP request -} else { - // in case of nil, the token is no longer valid -} -``` - -### Removing Token Locally - -The token store exposes the `removeLocalToken()` method, but the implementation does nothing. - -### Removing Token From the Server - -The token store exposes the `removeAccessToken()` method, but the implementation always returns the `PowerAuthErrorCode.invalidToken` error. - -## Common SDK Tasks - -### Error Handling - -You can follow the same practices as for iOS SDK because the Extensions SDK codebase shares the same error constants with a full PowerAuth SDK for iOS. - -### Debug Build Detection - -It is sometimes useful to switch Extensions SDK to a DEBUG build configuration, to get more logs from the library: - -- **CocoaPods:** we currently don't provide DEBUG pod. This will be resolved in some future versions of Extensions SDK. -- **Manual installation:** Xcode matches build configuration across all nested projects, so you usually don't need to care about the configuration switching. - -The DEBUG build is usually helpful during application development, but on the other side, it's highly unwanted in production applications. For this purpose, the `PowerAuthSystem.isInDebug()` method provides information on whether the PowerAuth for Extensions library was compiled in DEBUG configuration. It is a good practice to check this flag and crash the process when the production application is linked against the DEBUG library: - -```swift -#if YOUR_APPSTORE_BUILD_FLAG - // Final vs Debug library trap - if PowerAuthSystem.isInDebug() { - fatalError("CRITICAL ERROR: You're using Debug PowerAuth library in production build.") - } -#endif -``` - -## Troubleshooting - -This section of the document contains various workarounds and tips for Extensions SDK usage. - -### UserDefaults Migration - -If your previous version of the application did not use shared data between the application and the extension, then you probably need to migrate the keychain status flag from `UserDefaults.standard` to a shared one. We recommend performing this migration at the main application's startup code and **BEFORE** the `PowerAuthSDK` object is configured and used: - -```swift -private func migrateUserDefaults() { - let keychainConfig = PowerAuthKeychainConfiguration.sharedInstance() - let suiteName = keychainConfig.keychainAttribute_UserDefaultsSuiteName - guard let shared = UserDefaults(suiteName: suiteName) else { - return // data sharing is probably not configured properly - } - if shared.bool(forKey: PowerAuthKeychain_Initialized) { - return // migration is not required - } - let standard = UserDefaults.standard - if standard.bool(forKey: PowerAuthKeychain_Initialized) { - standard.removeObject(forKey: PowerAuthKeychain_Initialized) - standard.synchronize() - shared.set(true, forKey: PowerAuthKeychain_Initialized) - shared.synchronize() - } -} -``` diff --git a/docs/PowerAuth-SDK-for-iOS.md b/docs/PowerAuth-SDK-for-iOS.md index 507f6f4d..31124f60 100644 --- a/docs/PowerAuth-SDK-for-iOS.md +++ b/docs/PowerAuth-SDK-for-iOS.md @@ -6,7 +6,6 @@ - [Installation](#installation) - [Supported Platforms](#supported-platforms) - [CocoaPods Installation](#cocoapods) - - [Manual Installation](#manual) - [Carthage Installation](#carthage) - [Post-Installation Steps](#post-installation-steps) - [Include PowerAuth SDK in Your Sources](#include-powerauth-sdk-in-your-sources) @@ -52,13 +51,12 @@ Related documents: -- [PowerAuth SDK for iOS App Extensions](./PowerAuth-SDK-for-iOS-Extensions.md) - [PowerAuth SDK for watchOS](./PowerAuth-SDK-for-watchOS.md) ## Installation -This chapter describes how to get PowerAuth SDK for iOS and tvOS up and running in your app. In the current version, you can choose between CocoaPods and manual library integration. +This chapter describes how to get PowerAuth SDK for iOS and tvOS up and running in your app. In the current version, you can choose between CocoaPods and Swift Package Manager library integration. ### Supported Platforms @@ -97,25 +95,6 @@ $ pod install If you wish to integrate the PowerAuth SDK into your app via SPM, please visit the [PowerAuth mobile SDK for Swift PM ](https://github.com/wultra/powerauth-mobile-sdk-spm) -### Manual - -If you prefer not to use CocoaPods as a dependency manager, you can integrate PowerAuth into your project manually as a git [submodule](http://git-scm.com/docs/git-submodule). - -#### Git Submodules - -1. Open up the Terminal app and go to your top-level project directory and add the library as a submodule: - ```sh - $ git submodule add https://github.com/wultra/powerauth-mobile-sdk.git PowerAuthLib - $ git submodule update --init --recursive - ``` - The first command will clone PowerAuth SDK into the `PowerAuthLib` folder, and the second will update all nested submodules. - -2. Open the new `PowerAuthLib` folder, and go to the `proj-xcode` sub-folder -3. Drag the `PowerAuthLib.xcodeproj` project file into **Project Navigator** of your application's Xcode project. It should appear nested underneath your application's blue project icon. -4. Select your application project in the Project Navigator to navigate to the target configuration window and select the extension's target under the **TARGETS** heading in the sidebar. -5. Now select **Build Phases** tab and expand the **Target Dependencies** section. Click on the "Plus Sign" and choose the **"PowerAuth2"** framework from the **"PowerAuthLib"** project. -6. Next, in the same **Build Phases** tab, expand **Link With Libraries** section. Click on the "Plus Sign" and choose the **"PowerAuth2.framework"** from the **"PowerAuthLib"** project. - ### Carthage We provide limited and experimental support for the [Carthage dependency manager](https://github.com/Carthage/Carthage). The current problem with Carthage is that we cannot specify which Xcode project and which scheme has to be used for a particular library build. It kind of works automatically, but the build process is extremely slow. So, if you still want to try to integrate our library with Carthage, try the following tips: diff --git a/docs/PowerAuth-SDK-for-watchOS.md b/docs/PowerAuth-SDK-for-watchOS.md index 4df76ed6..99ab2bf3 100644 --- a/docs/PowerAuth-SDK-for-watchOS.md +++ b/docs/PowerAuth-SDK-for-watchOS.md @@ -5,7 +5,6 @@ - [Installation](#installation) - [CocoaPods Installation](#cocoapods) - - [Manual Installation](#manual) - [SDK Configuration](#configuration) - [Prepare Watch Connectivity](#prepare-watch-connectivity) - [Configure PowerAuth for WatchKit](#configure-powerauth-for-watchkit) @@ -22,7 +21,6 @@ Related documents: - [PowerAuth SDK for iOS](./PowerAuth-SDK-for-iOS.md) / or go directly to [Apple Watch section](./PowerAuth-SDK-for-iOS.md#apple-watch-support) -- [PowerAuth SDK for iOS App Extensions](./PowerAuth-SDK-for-iOS-Extensions.md) ## Installation @@ -66,27 +64,6 @@ $ pod install Check [troubleshooting section](#cocoapods-integration-fails) of this document when `pod update` or `pod install` doesn't work. -### Manual - -If you prefer not to use CocoaPods as dependency manager, you can integrate Watch SDK into your project manually as a git [submodule](http://git-scm.com/docs/git-submodule). - -#### Git Submodules - -The integration process is quite similar to integration of our library for IOS: - -1. Open up the Terminal.app and go to your top-level project directory and add the library as a submodule: - ```sh - $ git submodule add https://github.com/wultra/powerauth-mobile-sdk.git PowerAuthLib - $ git submodule update --init --recursive - ``` - The first command will clone PowerAuth SDK into the `PowerAuthLib` folder and second will update all nested submodules. We're expecting that you already did this when you integrated PowerAuth into your application. - -2. Open the new `PowerAuthLib` folder, and go to the `proj-xcode` sub-folder -3. Drag the `PowerAuthExtensionSdk.xcodeproj` project file into **Project Navigator** of your application's Xcode project. It should appear nested underneath your application's blue project icon. -4. Select your application project in the Project Navigator to navigate to the target configuration window and select the watch app's target under the **TARGETS** heading in the sidebar. -5. Now select **Build Phases** tab and expand **Target Dependencies** section. Click on the "Plus Sign" and choose **"PowerAuth2ForWatch"** framework from the **"PowerAuthExtensionSdk"** project. -6. Next, in the same **Build Phases** tab expand **Link With Libraries** section. Click on the "Plus Sign" and choose **"PowerAuth2ForWatch.framework"** from the **"PowerAuthExtensionSdk"** project. - ## Configuration The Watch SDK shares several source codes and configuration principles with the main iOS SDK. So, you can prepare the same set of constants as you're already using in your IOS application. The SDK provides just a limited functionality for the watch app (for example, you cannot create an activation or calculate a full PowerAuth signature from a watch application) and to do that it requires that your application's code will participate in data synchronization. diff --git a/docs/Readme.md b/docs/Readme.md index ace5d819..73519fd9 100644 --- a/docs/Readme.md +++ b/docs/Readme.md @@ -5,7 +5,6 @@ To connect to the [PowerAuth](https://www.wultra.com/product/powerauth-mobile-se ## Integration Tutorials - [PowerAuth SDK for iOS and tvOS Apps](PowerAuth-SDK-for-iOS.md) -- [PowerAuth SDK for iOS and tvOS Extensions](PowerAuth-SDK-for-iOS-Extensions.md) - [PowerAuth SDK for watchOS](PowerAuth-SDK-for-watchOS.md) - [PowerAuth SDK for Android Apps](PowerAuth-SDK-for-Android.md) diff --git a/docs/_Sidebar.md b/docs/_Sidebar.md index b7f90e59..a12ee3a4 100644 --- a/docs/_Sidebar.md +++ b/docs/_Sidebar.md @@ -7,7 +7,6 @@ **Integration Tutorials** - [iOS Applications](./PowerAuth-SDK-for-iOS.md) -- [iOS App Extensions](./PowerAuth-SDK-for-iOS-Extensions.md) - [watchOS Applications](./PowerAuth-SDK-for-watchOS.md) - [Android Applications](./PowerAuth-SDK-for-Android.md)