Skip to content

Commit

Permalink
Candidate merge for v5.3.1 (#523)
Browse files Browse the repository at this point in the history
* [MINI-6142] Access token hot fix (#521)

* Hotfix release changes

* Swiftlint fix

* Swiftlint

* Swiftlint

* Update Sources/Classes/core/View/MiniAppView.swift

Co-authored-by: pierremichel.villa <[email protected]>

---------

Co-authored-by: pierremichel.villa <[email protected]>

* MAAnalyticsInfo fix

* Updated marketing version

---------

Co-authored-by: pierremichel.villa <[email protected]>
  • Loading branch information
rleojoseph and Climbatize authored Aug 2, 2023
1 parent e609ad3 commit 3e71eb1
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 18 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
## CHANGELOG

### 5.3.1 (2023-08-02)
**SDK**
- **Feature:** Updated `loadFromBundle(miniAppManifest:completionHandler)` interface with optional MiniAppManifest object.
- **Feature:** Added a new property in MiniAppViewable class to Enable/Disable 3D touch for the Miniapp that is launched.
- **Fix:** Enable variables to public for `MAAnalyticsInfo`

**Sample App**
- **Feature:** Updated Sample app to send `miniAppManifest` while loading from bundle
- **Feature:** Hardcoded permissions for `loadFromBundle` approach
---

### 5.3.0 (2023-07-25)
**SDK**
- **Deprecated:** `create(appInfo: ,queryParams: ,completionHandler: ,messageInterface: ,adsDisplayer: ,fromCache: ) in `MiniApp` class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@ struct MiniAppFromBundle: View {

@State var isMiniAppLoading: Bool = false

init() {
MiniApp.shared(with: ListConfiguration(listType: .listI).sdkConfig).setCustomPermissions(forMiniApp: "mini-app-testing-appid", permissionList: permissionList())
}
var body: some View {
VStack {
MiniAppSUIView(params: miniAppViewParams(config: ListConfiguration(listType: .listI).sdkConfig), fromCache: true, handler: MiniAppSUIViewHandler(), fromBundle: true)
MiniAppSUIView(params: miniAppViewParams(config: ListConfiguration(listType: .listI).sdkConfig),
fromCache: true,
handler: MiniAppSUIViewHandler(),
fromBundle: true,
miniAppManifest: getMiniAppManifest())
}
.navigationTitle(MiniAppSDKConstants.miniAppRootFolderName)
}
Expand All @@ -27,4 +34,38 @@ struct MiniAppFromBundle: View {
queryParams: getQueryParam()
)
}

func getMiniAppManifest() -> MiniAppManifest? {
return MiniAppManifest(requiredPermissions: permissionList(),
optionalPermissions: nil,
customMetaData: nil,
accessTokenPermissions: [MASDKAccessTokenScopes(audience: "rae",
scopes: ["idinfo_read_openid", "memberinfo_read_point"])!],
versionId: "")
}

private func permissionList() -> [MASDKCustomPermissionModel] {
do {
let permissions: [MiniAppCustomPermissionType] = [.userName, .profilePhoto, .contactsList, .fileDownload, .accessToken, .deviceLocation, .sendMessage, .points]

return try permissions.map { try MASDKCustomPermissionModel.customPermissionModel(permissionName: $0) }
} catch {
print("Failed to set up MiniApp permissions")
return []
}
}
}

extension MASDKCustomPermissionModel {
static func customPermissionModel(permissionName: MiniAppCustomPermissionType, isPermissionGranted: MiniAppCustomPermissionGrantedStatus = .allowed, permissionRequestDescription: String? = "") throws -> Self {
let data = [
"permissionName": permissionName.rawValue,
"isPermissionGranted": isPermissionGranted.rawValue,
"permissionDescription": permissionRequestDescription
]

let encodedData = try JSONEncoder().encode(data)

return try JSONDecoder().decode(Self.self, from: encodedData)
}
}
2 changes: 1 addition & 1 deletion MiniApp.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |miniapp|
miniapp.name = 'MiniApp'
miniapp.version = '5.3.0'
miniapp.version = '5.3.1'
miniapp.authors = "Rakuten Ecosystem Mobile"
miniapp.summary = "Rakuten's Mini App SDK"
miniapp.description = "This open-source library allows you to integrate Mini App ecosystem into your iOS applications. Mini App SDK also facilitates communication between a mini app and the host app via a message bridge."
Expand Down
4 changes: 2 additions & 2 deletions MiniAppCarthage/MiniApp/MiniApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,7 @@
"@executable_path/Frameworks",
);
MACH_O_TYPE = staticlib;
MARKETING_VERSION = 5.3.0;
MARKETING_VERSION = 5.3.1;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = com.rakuten.tech.mobile.MiniApp;
PRODUCT_NAME = MiniApp;
Expand Down Expand Up @@ -1361,7 +1361,7 @@
"@executable_path/Frameworks",
);
MACH_O_TYPE = staticlib;
MARKETING_VERSION = 5.3.0;
MARKETING_VERSION = 5.3.1;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = com.rakuten.tech.mobile.MiniApp;
PRODUCT_NAME = MiniApp;
Expand Down
2 changes: 1 addition & 1 deletion Sources/Classes/core/MiniApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import UIKit

/// Mini App Public API methods
public class MiniApp: NSObject {
public static let version = "5.3.0"
public static let version = "5.3.1"
private static let shared = MiniApp()
private let realMiniApp = RealMiniApp()
public static var MAOrientationLock: UIInterfaceOrientationMask = []
Expand Down
12 changes: 6 additions & 6 deletions Sources/Classes/core/Models/MAAnalyticsInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public enum MAAnalyticsActionType: String, Codable {
}

public class MAAnalyticsInfo: Codable {
let eventType: MAAnalyticsEventType
let actionType: MAAnalyticsActionType
let pageName: String
let componentName: String
let elementType: String
let data: String
public let eventType: MAAnalyticsEventType
public let actionType: MAAnalyticsActionType
public let pageName: String
public let componentName: String
public let elementType: String
public let data: String

public init(eventType: MAAnalyticsEventType,
actionType: MAAnalyticsActionType,
Expand Down
16 changes: 14 additions & 2 deletions Sources/Classes/core/View/MiniAppView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ public class MiniAppView: UIView, MiniAppViewable {
}
var cancellables = Set<AnyCancellable>()

fileprivate var enableLinkPreview: Bool = true

public var enable3DTouch: Bool {
get {
return enableLinkPreview
}
set {
enableLinkPreview = newValue
}
}

public init(params: MiniAppViewParameters) {
switch params {
case let .default(params):
Expand Down Expand Up @@ -98,6 +109,7 @@ public class MiniAppView: UIView, MiniAppViewable {

internal func setupWebView(webView: MiniAppWebView) {
self.webView = webView
self.webView?.allowsLinkPreview = enableLinkPreview
webView.translatesAutoresizingMaskIntoConstraints = false
self.addSubview(webView)
NSLayoutConstraint.activate([
Expand Down Expand Up @@ -163,13 +175,13 @@ public class MiniAppView: UIView, MiniAppViewable {
}
}

public func loadFromBundle(completion: @escaping ((Result<Bool, MASDKError>) -> Void)) {
public func loadFromBundle(miniAppManifest: MiniAppManifest?, completion: @escaping ((Result<Bool, MASDKError>) -> Void)) {
guard webView == nil else {
completion(.failure(miniAppAlreadyLoadedError))
return
}
state.send(.loading)
miniAppHandler.loadFromBundle { [weak self] result in
miniAppHandler.loadFromBundle(miniAppManifest: miniAppManifest) { [weak self] result in
switch result {
case let .success(webView):
self?.state.send(.active)
Expand Down
10 changes: 9 additions & 1 deletion Sources/Classes/core/View/MiniAppViewHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,12 @@ class MiniAppViewHandler: NSObject {
}
}

func loadFromBundle(completion: @escaping ((Result<MiniAppWebView, MASDKError>) -> Void)) {
func loadFromBundle(miniAppManifest: MiniAppManifest? = nil, completion: @escaping ((Result<MiniAppWebView, MASDKError>) -> Void)) {
guard let versionId = version else {
completion(.failure(.invalidVersionId))
return
}
saveManifestInfoForBundle(miniAppManifest: miniAppManifest)
if isValidMiniAppInfo(versionId: versionId) {
if isMiniAppAvailable(versionId: versionId) {
if miniAppDownloader.isCacheSecure(appId: appId, versionId: versionId) {
Expand Down Expand Up @@ -328,6 +329,13 @@ class MiniAppViewHandler: NSObject {
}
}

func saveManifestInfoForBundle(miniAppManifest: MiniAppManifest?) {
guard let manifest = miniAppManifest else {
return
}
miniAppManifestStorage.saveManifestInfo(forMiniApp: appId, manifest: manifest)
}

func loadWebView(
webView: MiniAppWebView,
miniAppTitle: String = MiniAppSDKConstants.miniAppRootFolderName,
Expand Down
7 changes: 7 additions & 0 deletions Sources/Classes/core/View/MiniAppViewable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public protocol MiniAppViewable: UIView, MiniAppNavigationBarDelegate {
///
var alertInfo: CloseAlertInfo? { get }

var enable3DTouch: Bool { get }

func loadFromBundle(miniAppManifest: MiniAppManifest?, completion: @escaping ((Result<Bool, MASDKError>) -> Void))
}

public extension MiniAppViewable {
Expand All @@ -44,4 +47,8 @@ public extension MiniAppViewable {
func loadAsync(fromCache: Bool = false) async throws -> MiniAppView.MiniAppLoadStatus {
try await loadAsync(fromCache: fromCache)
}

func loadFromBundle(miniAppManifest: MiniAppManifest? = nil, completion: @escaping ((Result<Bool, MASDKError>) -> Void)) {
loadFromBundle(miniAppManifest: miniAppManifest, completion: completion)
}
}
9 changes: 7 additions & 2 deletions Sources/Classes/ui/MiniAppSUIView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ public struct MiniAppSUIView: UIViewRepresentable {
var fromCache: Bool = false
var fromBundle: Bool = false

public init(params: MiniAppViewParameters.DefaultParams, fromCache: Bool = false, handler: MiniAppSUIViewHandler, fromBundle: Bool = false) {
// This parameter will be used for loadFromBundle only
var miniAppManifest: MiniAppManifest?

public init(params: MiniAppViewParameters.DefaultParams, fromCache: Bool = false, handler: MiniAppSUIViewHandler, fromBundle: Bool = false, miniAppManifest: MiniAppManifest? = nil) {
self.params = .default(params)
self.fromCache = fromCache
self.handler = handler
self.fromBundle = fromBundle
self.miniAppManifest = miniAppManifest
}

public init(urlParams: MiniAppViewParameters.UrlParams) {
Expand All @@ -33,7 +37,8 @@ public struct MiniAppSUIView: UIViewRepresentable {
let view = MiniAppView(params: params)
view.progressStateView = MiniAppProgressView()
if fromBundle {
view.loadFromBundle {_ in
view.enable3DTouch = false
view.loadFromBundle(miniAppManifest: miniAppManifest) {_ in
self.handler.isActive = true
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/MiniAppScriptMessageHandlerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ class MiniAppScriptMessageHandlerTests: QuickSpec {
return
}
let environmentInfo = ResponseDecoder.decode(decodeType: MAHostEnvironmentInfo.self, data: responseData)
expect(environmentInfo?.sdkVersion).toEventually(equal("5.3.0"))
expect(environmentInfo?.sdkVersion).toEventually(equal("5.3.1"))
expect(environmentInfo?.hostVersion).toEventually(equal(Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String))
expect(environmentInfo?.hostLocale).toEventually(equal("en-US"))
}
Expand Down
2 changes: 1 addition & 1 deletion USERGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ To integrate MiniApp SDK into your Xcode project using Swift Package Manager, ad

```ruby
dependencies: [
.package(url: "https://github.com/rakutentech/ios-miniapp.git", .upToNextMajor(from: "5.3.0"))
.package(url: "https://github.com/rakutentech/ios-miniapp.git", .upToNextMajor(from: "5.3.1"))
]
```

Expand Down

0 comments on commit 3e71eb1

Please sign in to comment.