Skip to content

Commit

Permalink
Merge pull request #54 from MetaMask/dapp-platform
Browse files Browse the repository at this point in the history
Add device platform in dapp metadata
  • Loading branch information
elefantel authored Feb 14, 2023
2 parents decdcfd + 6123864 commit ada7983
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Example/metamask-ios-sdk/SwitchChainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ struct SwitchChainView: View {
.modifier(ButtonStyle())
}
}
.onAppear {
networkSelection = ethereum.chainId == networkSelection.rawValue
? .ethereum
: .goerli
}
.background(Color.blue.grayscale(0.5))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ extension SocketClient {
func sendOriginatorInfo() {
let originatorInfo = OriginatorInfo(
title: dapp?.name,
url: dapp?.url
url: dapp?.url,
platform: SDKInfo.platform
)

let requestInfo = RequestInfo(
Expand Down Expand Up @@ -361,7 +362,7 @@ extension SocketClient {
"sdkVersion": SDKInfo.version,
"url": dapp?.url ?? "",
"title": dapp?.name ?? "",
"platform": UIDevice.current.systemName
"platform": SDKInfo.platform
]
parameters.merge(additionalParams) { current, _ in current }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ public typealias CodableData = Codable & SocketData
struct OriginatorInfo: CodableData {
let title: String?
let url: String?
let platform: String?

func socketRepresentation() -> NetworkData {
["title": title ?? "", "url": url ?? ""]
[
"title": title,
"url": url,
"platform": platform
]
}
}

Expand Down
1 change: 1 addition & 0 deletions Sources/metamask-ios-sdk/Classes/Ethereum/Dapp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Foundation
public struct Dapp {
public let name: String
public let url: String
var platform: String = "ios"

public init(name: String, url: String) {
self.name = name
Expand Down
8 changes: 7 additions & 1 deletion Sources/metamask-ios-sdk/Classes/SDK/SDKInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// SDKInfo.swift
//

import UIKit
import Foundation

struct SDKInfo {
enum SDKInfo {
/// Bundle with SDK plist
static var sdkBundle: [String: Any] {
Bundle(for: MetaMaskSDK.self).infoDictionary ?? [:]
Expand All @@ -14,4 +15,9 @@ struct SDKInfo {
static var version: String {
sdkBundle["CFBundleShortVersionString"] as? String ?? ""
}

/// The platform OS on which the SDK is run e.g `ios, ipados`
static var platform: String {
UIDevice.current.systemName.lowercased()
}
}

0 comments on commit ada7983

Please sign in to comment.