Commit 883a1faf authored by shigemi miura's avatar shigemi miura

バージョンアップ処理

parent 41876a5c
...@@ -9,7 +9,6 @@ import Foundation ...@@ -9,7 +9,6 @@ import Foundation
class AppVersionModel: ObservableObject { class AppVersionModel: ObservableObject {
private var serverSession = ServerSession() private var serverSession = ServerSession()
let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString")
func start() { func start() {
...@@ -25,7 +24,9 @@ class AppVersionModel: ObservableObject { ...@@ -25,7 +24,9 @@ class AppVersionModel: ObservableObject {
let json = try JSONSerialization.jsonObject(with: appData, options: [.allowFragments]) as? [String: Any] let json = try JSONSerialization.jsonObject(with: appData, options: [.allowFragments]) as? [String: Any]
guard let result = (json?["results"] as? [Any])?.first as? [String: Any], guard let result = (json?["results"] as? [Any])?.first as? [String: Any],
let storeVersion = result["version"] as? String else { return } let storeVersion = result["version"] as? String else { return }
print(debug: "\(storeVersion)") if let app = self.appVersion as? String {
SharingData.my.isUpDate = storeVersion.versionCompare(app) == .orderedDescending
}
} catch { } catch {
print(error) print(error)
} }
...@@ -44,27 +45,23 @@ class AppVersionModel: ObservableObject { ...@@ -44,27 +45,23 @@ class AppVersionModel: ObservableObject {
} }
serverSession.getJson(req_url, completion: completion) serverSession.getJson(req_url, completion: completion)
} }
}
// func appVersionCheck() { /**
// guard let info = Bundle.main.infoDictionary, * Version番号比較
// let appVersion = info["CFBundleShortVersionString"] as? String, * メジャーバージョン・マイナーバージョン・リビジョンバージョン
// let identifier = info["CFBundleIdentifier"] as? String, * マイナーバージョン以上が変更された場合
// let url = URL(string: "https://itunes.apple.com/lookup?bundleId=\(identifier)") else { return } */
// extension String {
// let task = URLSession.shared.dataTask(with: url) { (data, response, error) in func versionCompare(_ otherVersion: String) -> ComparisonResult {
// guard let data = data else { return } let delimiter = "."
// do { var versionComponents = self.components(separatedBy: delimiter)
// let json = try JSONSerialization.jsonObject(with: data, options: [.allowFragments]) as? [String: Any] var otherComponents = otherVersion.components(separatedBy: delimiter)
// guard let result = (json?["results"] as? [Any])?.first as? [String: Any],
// let storeVersion = result["version"] as? String else { return } versionComponents[2] = "0"
// otherComponents[2] = "0"
// if appVersion != storeVersion {
// // appVersion と storeVersion が異なっている時に実行したい処理を記述 return versionComponents.joined(separator: delimiter)
// } .compare(otherComponents.joined(separator: delimiter), options: .numeric)
// } catch let error { }
// print(error)
// }
// }
// task.resume()
// }
} }
...@@ -29,10 +29,10 @@ enum HttpRequestType : String { ...@@ -29,10 +29,10 @@ enum HttpRequestType : String {
case GetManualUrl = "https://ssv-canary-web.azurewebsites.net/api/constantdata/manual?filter=SailAssist" case GetManualUrl = "https://ssv-canary-web.azurewebsites.net/api/constantdata/manual?filter=SailAssist"
case ContactPage = "https://www.jmarinecloud.com/eng/contact.php?type=ssv_mobile" case ContactPage = "https://www.jmarinecloud.com/eng/contact.php?type=ssv_mobile"
case ApachLicens = "https://raw.githubusercontent.com/Azure/azure-notificationhubs-ios/main/LICENSE" case ApachLicens = "https://raw.githubusercontent.com/Azure/azure-notificationhubs-ios/main/LICENSE"
case AppStore = "https://apps.apple.com/jp/app/ssv-mobile/id1434022656" // case AppStore = "https://apps.apple.com/jp/app/ssv-mobile/id1434022656"
case AppInfo = "https://itunes.apple.com/lookup?bundleId=com.jrc.tacmi" // case AppInfo = "https://itunes.apple.com/lookup?bundleId=com.jrc.tacmi"
// case AppStore = "https://apps.apple.com/jp/app/sail-assist/id6473762428" case AppStore = "https://apps.apple.com/jp/app/sail-assist/id6473762428"
// case AppInfo = "https://itunes.apple.com/lookup?bundleId=com.jrc.sailassist" case AppInfo = "https://itunes.apple.com/lookup?bundleId=com.jrc.sailassist"
} }
#elseif QC #elseif QC
enum HttpRequestType : String { enum HttpRequestType : String {
......
...@@ -83,6 +83,8 @@ struct MapTaskView: View { ...@@ -83,6 +83,8 @@ struct MapTaskView: View {
.frame(height: 55) .frame(height: 55)
} }
.onAppear{ .onAppear{
let appVersionModel = AppVersionModel()
appVersionModel.start()
EcaCoordinatesTable().setEcaData() EcaCoordinatesTable().setEcaData()
} }
.alert("", isPresented: $eca.isShowEcaAlert) { .alert("", isPresented: $eca.isShowEcaAlert) {
......
...@@ -28,13 +28,20 @@ struct MenuGpsSelectView: View { ...@@ -28,13 +28,20 @@ struct MenuGpsSelectView: View {
var body: some View { var body: some View {
VStack{ VStack{
MenuTitleView(path: $path, title: MenuPath.Setting.title) MenuTitleView(path: $path, title: MenuPath.Setting.title)
ForEach(GpsSelect.allCases, id:\.rawValue){ content in ForEach(GpsSelect.allCases, id:\.rawValue){ content in
SelectContentView(selected: $selected, content: content) SelectContentView(selected: $selected, content: content)
} }
Spacer() Spacer()
} }
.background(ColorSet.BackgroundPrimary.color) .background(ColorSet.BackgroundPrimary.color)
.onAppear{
if Preferences.LocationType == 0{
selected = .Mobile
}else{
selected = .Cloud
}
}
} }
struct SelectContentView: View { struct SelectContentView: View {
...@@ -76,7 +83,6 @@ struct MenuGpsSelectView: View { ...@@ -76,7 +83,6 @@ struct MenuGpsSelectView: View {
} }
} }
} }
} }
#Preview { #Preview {
......
...@@ -28,7 +28,7 @@ class SharingData{ ...@@ -28,7 +28,7 @@ class SharingData{
@Published var shipName: String = "" @Published var shipName: String = ""
@Published var imo: Int = 0 @Published var imo: Int = 0
@Published var mmsi: Int = 0 @Published var mmsi: Int = 0
@Published var company: String = "JRC Co.,Ltd" @Published var isUpDate: Bool = false
@Published var ecaStatus: EcaState? @Published var ecaStatus: EcaState?
......
...@@ -23,7 +23,6 @@ enum Tab: String, CaseIterable{ ...@@ -23,7 +23,6 @@ enum Tab: String, CaseIterable{
struct MainTabView: View { struct MainTabView: View {
@EnvironmentObject var selectedTabModel: SelectedTabModel @EnvironmentObject var selectedTabModel: SelectedTabModel
@EnvironmentObject private var sceneDelegate: SceneDelegate @EnvironmentObject private var sceneDelegate: SceneDelegate
@ObservedObject var my = SharingData.my
@State var isSignout = false @State var isSignout = false
@State var isLogin = false @State var isLogin = false
...@@ -69,6 +68,8 @@ struct MainTabView: View { ...@@ -69,6 +68,8 @@ struct MainTabView: View {
struct CustomTabBar: View { struct CustomTabBar: View {
@EnvironmentObject private var selectedTabModel: SelectedTabModel @EnvironmentObject private var selectedTabModel: SelectedTabModel
@State var isLocationAlert = false @State var isLocationAlert = false
@Environment(\.openURL) var openURL
@ObservedObject var my = SharingData.my
var body: some View { var body: some View {
VStack(spacing: 0){ VStack(spacing: 0){
...@@ -116,6 +117,13 @@ struct CustomTabBar: View { ...@@ -116,6 +117,13 @@ struct CustomTabBar: View {
} message: { } message: {
Text("To use ECA,set the permission to use location information to ALWAYS.") Text("To use ECA,set the permission to use location information to ALWAYS.")
} }
.alert("Update", isPresented: $my.isUpDate) {
Button("Go to app page"){
openURL(URL(string: HttpRequestType.AppStore.rawValue)!)
}
} message: {
Text("A new version of this app is available.")
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment