Commit 1e705b85 authored by shigemi miura's avatar shigemi miura

ECAタスク

Push通知
parent 9c00f333
......@@ -1140,6 +1140,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Sailassist/Sailassist.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"Sailassist/Preview Content\"";
......@@ -1169,6 +1170,7 @@
OTHER_SWIFT_FLAGS = "-D CANARY -D COCOAPODS";
PRODUCT_BUNDLE_IDENTIFIER = com.jrc.sailassist.canary;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
......
......@@ -31,8 +31,8 @@
</TestAction>
<LaunchAction
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
......
......@@ -8,7 +8,7 @@
import Foundation
import CoreLocation
#if false
#if true
//ECA Coordinates China
var chinaShore:[CLLocationCoordinate2D] = [
CLLocationCoordinate2D(latitude: 39.82805556, longitude: 124.16833333),
......@@ -4313,26 +4313,27 @@ class EcaCoordinatesTable : NSObject {
}
var ecaDataTable:[ecaData] = [
ecaData(id: 11, name: "North American Atlantic Coasts", table: northAmericanAtlanticCoasts)
// ecaData(id: 12, name: "North American Hawai", table: northAmericanHawai),
// ecaData(id: 31, name: "Unites States Caribbean", table: unitesStatesCaribbean),
// ecaData(id: 21, name: "North Sea 1", table: northSea1), //err
// ecaData(id: 22, name: "North Sea 2", table: northSea2),
// ecaData(id: 1, name: "Iceland", table: iceland),
// ecaData(id: 7, name: "China Shore", table: chinaShore),
// ecaData(id: 8, name: "China Hainan", table: chinaHainan),
// ecaData(id: 9, name: "China Yangtzi Shuifu,Yunnan", table: chinaYangtziShuifuYunnan), //err
// ecaData(id: 10, name: "China Yangtzi Liuhekou,Jiangsu1", table: chinaYangtziLiuhekouJiangsu1),
// ecaData(id: 11, name: "China Yangtzi Liuhekou,Jiangsu2", table: chinaYangtziLiuhekouJiangsu2),
// ecaData(id: 12, name: "China Xijiang Nanning,Guangxi", table: chinaXijiangNanningGuangxi), //err
// ecaData(id: 13, name: "China Xijiang Zhaoqing,Guangdong", table: chinaXijiangNanningGuangdong), //err
// ecaData(id: 14, name: "Korea Incheon, PyeongtaekDangjin Port", table: incheonPyeongtaekDanjinPort),
// ecaData(id: 15, name: "Korea Yeosu, Gwangyang Port", table: yeosuGwangyangPort),
// ecaData(id: 16, name: "Korea Busan Port", table: koreaBusanPort),
// ecaData(id: 17, name: "Korea Busan Port West", table: koreaBusanPortWest),
// ecaData(id: 18, name: "Korea Ulsan Port", table: koreaUlsanPort),
// ecaData(id: 19, name: "Panama Canal Atlantic Entrance", table: panamaCanalAtlanticEntrance),
// ecaData(id: 20, name: "Panama Canal Pacific Entrance", table: panamaCanalPacificEntrance)
ecaData(id: 1, name: "Iceland", table: iceland),
ecaData(id: 11, name: "North American Atlantic Coasts", table: northAmericanAtlanticCoasts),
ecaData(id: 12, name: "North American Hawai", table: northAmericanHawai),
ecaData(id: 13, name: "North American Pacific Coasts", table: northAmericanPacificCoasts),
ecaData(id: 21, name: "North Sea 1", table: northSea1), //err
ecaData(id: 22, name: "North Sea 2", table: northSea2),
ecaData(id: 31, name: "Unites States Caribbean", table: unitesStatesCaribbean),
ecaData(id: 41, name: "China Shore", table: chinaShore),
ecaData(id: 42, name: "China Hainan", table: chinaHainan),
ecaData(id: 43, name: "China Yangtzi Shuifu,Yunnan", table: chinaYangtziShuifuYunnan), //err
ecaData(id: 44, name: "China Yangtzi Liuhekou,Jiangsu1", table: chinaYangtziLiuhekouJiangsu1),
ecaData(id: 45, name: "China Yangtzi Liuhekou,Jiangsu2", table: chinaYangtziLiuhekouJiangsu2),
ecaData(id: 46, name: "China Xijiang Nanning,Guangxi", table: chinaXijiangNanningGuangxi), //err
ecaData(id: 47, name: "China Xijiang Zhaoqing,Guangdong", table: chinaXijiangNanningGuangdong), //err
ecaData(id: 51, name: "Korea Incheon, PyeongtaekDangjin Port", table: incheonPyeongtaekDanjinPort),
ecaData(id: 52, name: "Korea Yeosu, Gwangyang Port", table: yeosuGwangyangPort),
ecaData(id: 53, name: "Korea Busan Port", table: koreaBusanPort),
ecaData(id: 54, name: "Korea Busan Port West", table: koreaBusanPortWest),
ecaData(id: 55, name: "Korea Ulsan Port", table: koreaUlsanPort),
ecaData(id: 61, name: "Panama Canal Atlantic Entrance", table: panamaCanalAtlanticEntrance),
ecaData(id: 62, name: "Panama Canal Pacific Entrance", table: panamaCanalPacificEntrance)
]
func setEcaData() {
......
......@@ -46,9 +46,8 @@ class EcaTask {
SharingData.my.dataTime = res.dataTime //2023-11-02T05:25:49.4362123Z
SharingData.my.setLocation()
if Preferences.LocationType == 1 {
checkEca()
}
checkEca()
}
case .failure(let errorCode):
print(debug: errorCode)
......@@ -58,42 +57,92 @@ class EcaTask {
func checkEca() {
let runningEca = eca.ecaArea.first(where: {(key, value) in value.isRunning == true})
if let eca = runningEca?.value {
if var eca = runningEca?.value {
if let location = SharingData.my.location {
if let distance = LocationCalculation.checkPolyline(objPos: eca.points, shipPos: location) {
if var distance = LocationCalculation.checkPolyline(objPos: eca.points, shipPos: location) {
//起動時に状態を設定
if SharingData.my.ecaStatus == nil {
eca = runningEcaStatus(eca: eca, distance: distance)
}
if eca.swNotice >= Float(distance) && eca.status == EcaState.running {
notificationEca(point: SwitchingEca.Notice)
SharingData.eca.isShowEcaAlert = true
var newData = eca
newData.status = EcaState.noticePass
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Notice)
SharingData.my.ecaStatus = EcaState.noticePass
}
if eca.swStart >= Float(distance) && eca.status == EcaState.noticePass {
notificationEca(point: SwitchingEca.Start)
SharingData.eca.isShowEcaAlert = true
var newData = eca
newData.status = EcaState.startPass
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Start)
SharingData.my.ecaStatus = EcaState.startPass
}
if eca.swFinish >= Float(distance) && eca.status == EcaState.startPass {
if eca.swFinish >= Float(distance) && 0.0 < Float(distance) && eca.status == EcaState.startPass {
notificationEca(point: SwitchingEca.Finish)
SharingData.eca.isShowEcaAlert = true
var newData = eca
newData.status = EcaState.finishPass
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Finish)
SharingData.my.ecaStatus = EcaState.finishPass
}
if 0.0 <= Float(distance) && eca.status == EcaState.finishPass {
if 0.0 >= Float(distance) && eca.status == EcaState.startPass {
SharingData.eca.isShowEcaAlert = true
var newData = eca
newData.status = EcaState.incomplete
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Incomplete)
SharingData.my.ecaStatus = EcaState.incomplete
}
}
}
} else {
SharingData.my.ecaStatus = nil
}
}
func runningEcaStatus(eca: RegisteredEca, distance: Double) -> RegisteredEca {
var result = false
var newData = eca
if 0.0 >= Float(distance){
newData.status = EcaState.incomplete
result = true
}
if eca.swFinish >= Float(distance) && result == false{
newData.status = EcaState.startPass
result = true
}
if eca.swStart >= Float(distance) && result == false{
newData.status = EcaState.startPass
result = true
}
if eca.swNotice >= Float(distance) && result == false{
newData.status = EcaState.noticePass
}
return newData
}
func chengeEcaStatus(eca: RegisteredEca) {
if eca.status == EcaState.running {
var newData = eca
newData.status = EcaState.noticePass
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Notice)
}
if eca.status == EcaState.noticePass {
var newData = eca
newData.status = EcaState.startPass
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Start)
}
if eca.status == EcaState.startPass {
var newData = eca
newData.status = EcaState.finishPass
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Finish)
}
if eca.status == EcaState.finishPass {
var newData = eca
newData.status = EcaState.incomplete
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Incomplete)
}
}
}
......@@ -33,6 +33,9 @@ class GetEcaList {
if ecaList.status & serverRunning == serverRunning {
value.isRunning = true
value.status = setEcaServer(status: ecaList.status)
} else {
value.isRunning = false
value.status = EcaState.register
}
ecaData.ecaArea.updateValue(value, forKey: ecaList.taskName)
}
......@@ -45,9 +48,8 @@ class GetEcaList {
}
private func setEcaServer(status: Int) -> EcaState {
let statusInf = status ^ serverRunning
var state = EcaState.register
switch statusInf {
switch status {
case serverRunning:
state = EcaState.running
case serverNoticePass:
......
......@@ -21,9 +21,9 @@ enum EcaState {
let serverRegister = 0x00000000 //登録
let serverRunning = 0x10000000 //ECAタスク実行開始
let serverNoticePass = 0x00000001 //ECA通知円到達
let serverStartPass = 0x00000002 //ECA開始円到達
let serverFinishPass = 0x00000004 //ECAタスク終了円到達
let serverNoticePass = 0x10000001 //ECA通知円到達
let serverStartPass = 0x10000002 //ECA開始円到達
let serverFinishPass = 0x10000004 //ECAタスク終了円到達
let serverEnd = 0x00000100 //ECAタスク完了(燃料切替実施済み)
let serverIncomplete = 0x00000200 //ECAタスク未完了 (燃料切替未実施で終了)
let serverCancel = 0x00000400 //ECAタスクキャンセル (タスク終了・タスク未完了前にキャンセル)
......
......@@ -50,20 +50,38 @@ enum HttpRequestType : String {
//MARK: 運用サーバー用
enum HttpRequestType : String {
case Terms = "https://tacmistorage.blob.core.windows.net/$web/terms/terms.mobile.html?sv=2021-10-04&st=2023-11-22T06%3A26%3A32Z&se=2023-11-23T06%3A26%3A32Z&sr=b&sp=r&sig=wS6kbbT5SvNVTkRsnRk%2BiDceZAsQ3Y56vrqTUO1X50E%3D"
case RegisterLogin = "https://ssv.jmarinecloud.com/sailassistlogin"
case SitePolicy = "https://ssv.jmarinecloud.com/sitepolicy"
case CookiePolicy = "https://ssv.jmarinecloud.com/cookiepolicy"
case PrivacyPolicy = "https://ssv.jmarinecloud.com/inapp?" //+バージョン番号
case TaskList = "https://ssv.jmarinecloud.com/api/sailassist/tasklist/XXXXX"
case EcaArea = "https://ssv.jmarinecloud.com/api/sailassist/ecaarea"
case ShipStatus = "https://ssv.jmarinecloud.com/api/sailassist/shipstatus/XXXXX"
case ShipMonitoringRoute = "https://ssv.jmarinecloud.com/api/sailassist/shipmonitoringroute/XXXXX"
case GetMessage = "https://ssv.jmarinecloud.com/api/chatdata/getmessages?shipId=XXXXX"
case SignalR = "https://ssv.jmarinecloud.com/signalr/shore"
case PushHistory = "https://ssv.jmarinecloud.com/api/sailassist/pushhistory/XXXXX"
case UploadImage = "https://ssv.jmarinecloud.com/api/chatdata/uploadimage"
case ConnectionString = "Endpoint=sb://tacmihub.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=/IOJAYGLZmS2JvlsHT5aT+ETlPXqNt1+VGuMNDt4bzw="
case HubName = "tacmihub"
case storage = "https://tacmistorage.z31.web.core.windows.net/"
case RegisterLogin = "https://ssv-canary-web.azurewebsites.net/sailassistlogin"
case SitePolicy = "https://ssv-canary-web.azurewebsites.net/sitepolicy"
case CookiePolicy = "https://ssv-canary-web.azurewebsites.net/cookiepolicy"
case PrivacyPolicy = "https://ssv-canary-web.azurewebsites.net/inapp?" //+バージョン番号
case TaskList = "https://ssv-canary-web.azurewebsites.net/api/sailassist/tasklist/XXXXX"
case EcaArea = "https://ssv-canary-web.azurewebsites.net/api/sailassist/ecaarea/XXXXX"
case ShipStatus = "https://ssv-canary-web.azurewebsites.net/api/sailassist/shipstatus/XXXXX"
case ShipMonitoringRoute = "https://ssv-canary-web.azurewebsites.net/api/sailassist/shipmonitoringroute/XXXXX"
case GetMessage = "https://ssv-canary-web.azurewebsites.net/api/chatdata/getmessages?shipId=XXXXX"
case SignalR = "https://ssv-canary-web.azurewebsites.net/signalr/shore"
case PushHistory = "https://ssv-canary-web.azurewebsites.net/api/sailassist/pushhistory/XXXXX"
case UploadImage = "https://ssv-canary-web.azurewebsites.net/api/chatdata/uploadimage"
case ConnectionString = "Endpoint=sb://ssv-canary-notification.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=zHzVMA757FciMum5jVG4NMl82YpYVzclUgCiKOVRKf8="
case HubName = "ssv-canary-sailassist-notification"
case storage = "https://ssvcanarystorage.z1.web.core.windows.net/"
}
//enum HttpRequestType : String {
// case Terms = "https://tacmistorage.blob.core.windows.net/$web/terms/terms.mobile.html?sv=2021-10-04&st=2023-11-22T06%3A26%3A32Z&se=2023-11-23T06%3A26%3A32Z&sr=b&sp=r&sig=wS6kbbT5SvNVTkRsnRk%2BiDceZAsQ3Y56vrqTUO1X50E%3D"
// case RegisterLogin = "https://ssv.jmarinecloud.com/sailassistlogin"
// case SitePolicy = "https://ssv.jmarinecloud.com/sitepolicy"
// case CookiePolicy = "https://ssv.jmarinecloud.com/cookiepolicy"
// case PrivacyPolicy = "https://ssv.jmarinecloud.com/inapp?" //+バージョン番号
// case TaskList = "https://ssv.jmarinecloud.com/api/sailassist/tasklist/XXXXX"
// case EcaArea = "https://ssv.jmarinecloud.com/api/sailassist/ecaarea"
// case ShipStatus = "https://ssv.jmarinecloud.com/api/sailassist/shipstatus/XXXXX"
// case ShipMonitoringRoute = "https://ssv.jmarinecloud.com/api/sailassist/shipmonitoringroute/XXXXX"
// case GetMessage = "https://ssv.jmarinecloud.com/api/chatdata/getmessages?shipId=XXXXX"
// case SignalR = "https://ssv.jmarinecloud.com/signalr/shore"
// case PushHistory = "https://ssv.jmarinecloud.com/api/sailassist/pushhistory/XXXXX"
// case UploadImage = "https://ssv.jmarinecloud.com/api/chatdata/uploadimage"
// case ConnectionString = "Endpoint=sb://tacmihub.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=/IOJAYGLZmS2JvlsHT5aT+ETlPXqNt1+VGuMNDt4bzw="
// case HubName = "tacmihub"
// case storage = "https://tacmistorage.z31.web.core.windows.net/"
//}
#endif
......@@ -711,10 +711,10 @@ class LocationCalculation{
if (rtn1.retCode) {
distance = nil
} else {
distance = rtn1.xte
distance = rtn1.xte * -1
}
} else {
distance = rtn.xte
distance = rtn.xte * -1
}
if let dist = distance {
......@@ -869,7 +869,7 @@ class LocationCalculation{
if outside {
distance *= -1
}
print(debug: "checkPolyLine \(distance)")
print(debug: "pointsDistance \(distance)")
return (lineOut, distance)
}
......
......@@ -20,11 +20,12 @@ class LocationViewModel: NSObject, ObservableObject, CLLocationManagerDelegate {
super.init()
locationManager.delegate = self
locationManager.activityType = .automotiveNavigation
locationManager.distanceFilter = 100 //100mぐらい移動したら位置情報取得
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.allowsBackgroundLocationUpdates = true // バックグラウンド実行中も座標取得する場合、trueにする
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.distanceFilter = 10 //10mぐらい移動したら位置情報取得
locationManager.pausesLocationUpdatesAutomatically = false
locationManager.activityType = .otherNavigation
locationManager.startUpdatingLocation()
}
......@@ -39,14 +40,13 @@ class LocationViewModel: NSObject, ObservableObject, CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if let newLocation = locations.last {
lastSeenLocation = locations.first
print(debug: "called")
lastSeenLocation = newLocation
let targetCoordinate : CLLocationCoordinate2D = lastSeenLocation!.coordinate
SharingData.my.gps = targetCoordinate
SharingData.my.setLocation()
if Preferences.LocationType == 0 {
ecaTask.checkEca()
}
ecaTask.checkEca()
}
}
......
......@@ -181,7 +181,10 @@ struct LoginView: View {
Preferences.lastLoginDate_Int64 = DateTextLib.Date2UnixTime(date: Date())
isLogin = true
timer = Timer.scheduledTimer(withTimeInterval: 60.0, repeats: true) { _ in
// let ecaArea = EcaArea()
// ecaArea.start()
timer = Timer.scheduledTimer(withTimeInterval: 60.0 * 10, repeats: true) { _ in
print(debug: "called timer")
let eca = EcaTask()
eca.start()
......
......@@ -21,7 +21,7 @@ struct InputUserNameView: View {
var body: some View {
VStack{
VStack(alignment: .leading, spacing: 0) {
Text("JRC Ship")
Text(SharingData.my.company)
.font(FontStyle.TitleSBold.font)
.padding(.leading, 10)
.foregroundColor(.white)
......@@ -114,8 +114,11 @@ struct InputUserNameView: View {
let route = MonitoringRoute()
route.start()
// let ecaList = GetEcaList()
// ecaList.start()
let ecaList = GetEcaList()
ecaList.start()
let pushHistory = GetPushHistory()
pushHistory.start()
}
timer?.fire()
......
......@@ -27,7 +27,7 @@ struct MapTaskView: View {
@State var edittingEcaArea: RegisteredEca? = nil
@State var isShowSettingView : Bool = false
@ObservedObject var eca = SharingData.eca
var body: some View {
VStack{
Capsule()
......@@ -37,16 +37,15 @@ struct MapTaskView: View {
//タイトルエリア
HStack{
Button(action: {
viewMode = .SwitchingMenu
isShowSettingView = false
if var eca = SharingData.eca.ecaArea.map{ $0.1 }.filter{ $0.isRunning }.first{
eca.status = .noticePass
// SharingData.eca.editEcaArea(key: eca.name, value: eca)
// SharingData.eca.editEcaArea(key: eca.name, value: eca)
SharingData.eca.isShowEcaAlert = true
}
}, label: {
if viewMode != .SwitchingMenu || isShowSettingView{
......@@ -54,34 +53,30 @@ struct MapTaskView: View {
}
})
.frame(width: 48, height: 48)
Spacer()
Text(viewMode.title)
.font(FontStyle.TitleL.font)
.frame(height: 20)
.padding(.vertical, 14)
Spacer()
Button(action: {
}, label: {
})
.frame(width: 48, height: 48)
}
.padding(EdgeInsets(top: 10, leading: 8, bottom: 13, trailing: 17))
Divider()
.background(ColorSet.LineColor03.color)
ScrollView(.vertical){
switch viewMode {
case .SwitchingMenu:
......@@ -93,42 +88,53 @@ struct MapTaskView: View {
case .EcaList:
EcaListView()
}
}
Spacer()
.frame(height: 55)
}
.onAppear{
EcaCoordinatesTable().setEcaData()
}
.alert("", isPresented: $eca.isShowEcaAlert) {
if var ecaArea = eca.ecaArea.map{ $0.1 }.filter{ $0.isRunning }.first, ecaArea.status == .finishPass{
Button("Yes"){
ecaArea.status = .end
}
Button("No"){
ecaArea.status = .incomplete
}
}else{
Button("OK"){
if var ecaArea = eca.ecaArea.map{ $0.1 }.filter{ $0.isRunning }.first{
if SharingData.my.ecaStatus == .finishPass{
Button("Yes"){
var newData = ecaArea
newData.isRunning = false
newData.status = EcaState.end
SharingData.eca.editEcaArea(key: ecaArea.name, value: newData, type: EcaOperation.Finish)
}
Button("No"){
var newData = ecaArea
newData.isRunning = false
newData.status = EcaState.incomplete
SharingData.eca.editEcaArea(key: ecaArea.name, value: newData, type: EcaOperation.Incomplete)
}
}else{
Button("OK"){
let ecaTask = EcaTask()
ecaTask.chengeEcaStatus(eca: ecaArea)
}
}
}
} message: {
if let ecaArea = eca.ecaArea.map{ $0.1 }.filter{ $0.isRunning }.first{
switch ecaArea.status{
case .noticePass:
Text("Arrived at advance notice point.")
case .startPass:
Text("Arrived at switching start point.")
case .finishPass:
Text("Have you finished \(ecaArea.name) fuel switching?")
case .incomplete:
Text("Have you finished \(ecaArea.name) fuel switching?\nIf you finish, you disable it.")
default:
Text("")
if let status = SharingData.my.ecaStatus {
switch status {
case .noticePass:
Text("Arrived at advance notice point.")
case .startPass:
Text("Arrived at switching start point.")
case .finishPass:
Text("Have you finished \(ecaArea.name) fuel switching?")
case .incomplete:
Text("Have you finished \(ecaArea.name) fuel switching?\nIf you finish, you disable it.")
default:
Text("")
}
}
}
}
......
......@@ -35,6 +35,7 @@ struct TaskSwitchingMenuView: View {
if isEcaAlert == false {
var newData = eca
newData.isRunning = true
newData.status = EcaState.running
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Running)
}
} label: {
......
......@@ -56,10 +56,10 @@ struct MenuView: View {
HStack {
VStack(alignment: .leading, spacing: 10){
Text("Japan Radio Co.,Ltd.")
Text(SharingData.my.company)
.font(FontStyle.TitleL.font)
.foregroundColor(ColorSet.Body.color)
Text("会社名一般")
Text("Company name general")
.font(FontStyle.EmphasisText.font)
.foregroundColor(ColorSet.BodyDescriptiion.color)
}
......
......@@ -66,18 +66,19 @@ class AppDelegate: NSObject, UIApplicationDelegate ,MSNotificationHubDelegate, M
return
}
if granted {
// MSNotificationHub.setLifecycleDelegate(self)
MSNotificationHub.setLifecycleDelegate(self)
UNUserNotificationCenter.current().delegate = self
// MSNotificationHub.setDelegate(self)
MSNotificationHub.setDelegate(self)
MSNotificationHub.start(connectionString: HttpRequestType.ConnectionString.rawValue, hubName: HttpRequestType.HubName.rawValue)
let notification = notificationTags()
notification.addTags()
// addTags()
}
}
application.registerForRemoteNotifications()
MSNotificationHub.start(connectionString: HttpRequestType.ConnectionString.rawValue, hubName: HttpRequestType.HubName.rawValue)
let notification = notificationTags()
notification.addTags()
return true
}
......@@ -88,17 +89,17 @@ class AppDelegate: NSObject, UIApplicationDelegate ,MSNotificationHubDelegate, M
return config
}
// func addTags() {
// if Preferences.shipId == 0 {
// let shipId = String(Preferences.shipId)
// let testTag = "aaa"
// let routeTag = "route-" + shipId
// let bamTag = "bam-" + shipId
// let taskAlertTag = "taskalert-" + shipId
// let sailassistTag = "sailassist-" + shipId
// MSNotificationHub.addTags([testTag, routeTag, bamTag, taskAlertTag, sailassistTag])
// }
// }
func addTags() {
if Preferences.shipId != 0 {
let shipId = String(Preferences.shipId)
let testTag = "aaa"
let routeTag = "route-" + shipId
let bamTag = "bam-" + shipId
let taskAlertTag = "taskalert-" + shipId
let sailassistTag = "sailassist-" + shipId
MSNotificationHub.addTags([testTag, routeTag, bamTag, taskAlertTag, sailassistTag])
}
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
print(debug: "called")
......@@ -144,6 +145,13 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
let userInfo = response.notification.request.content.userInfo
print(debug: userInfo)
if let custom = userInfo["key"] as? String {
print(debug: "called \(custom)")
if custom == "map" {
}
}
completionHandler()
}
}
......
......@@ -11,8 +11,8 @@ enum EcaOperation {
case Insert
case Delete
case Running
case Start
case Notice
case Start
case Finish
case Incomplete
case Change
......@@ -35,7 +35,10 @@ class SharingData{
@Published var shipName: String = ""
@Published var imo: Int = 0
@Published var mmsi: Int = 0
@Published var company: String = "JRC Co.,Ltd"
@Published var ecaStatus: EcaState?
func setLocation(){
if Preferences.LocationType == 0 {
self.location = self.gps
......@@ -146,7 +149,7 @@ class SharingData{
case EcaOperation.Delete:
let deleteEcaArea = DeleteEcaArea()
deleteEcaArea.start(ecaId: value.id)
case EcaOperation.Start:
case EcaOperation.Notice:
task.areaId = value.id
task.taskName = value.name
task.noticeRange = value.swNotice
......@@ -156,7 +159,7 @@ class SharingData{
task.status = setEcaStatus(eca: value)
}
setEcaArea.start(eca: task)
case EcaOperation.Notice:
case EcaOperation.Start:
task.areaId = value.id
task.taskName = value.name
task.noticeRange = value.swNotice
......@@ -172,7 +175,7 @@ class SharingData{
task.noticeRange = value.swNotice
task.startRange = value.swStart
task.finishRange = value.swFinish
if value.isEnable && value.isRunning {
if value.isEnable {
task.status = setEcaStatus(eca: value)
}
setEcaArea.start(eca: task)
......@@ -182,7 +185,7 @@ class SharingData{
task.noticeRange = value.swNotice
task.startRange = value.swStart
task.finishRange = value.swFinish
if value.isEnable && value.isRunning {
if value.isEnable {
task.status = setEcaStatus(eca: value)
}
setEcaArea.start(eca: task)
......@@ -216,13 +219,13 @@ class SharingData{
case EcaState.running:
state = serverRunning
case EcaState.noticePass:
state = serverNoticePass + serverRunning
state = serverNoticePass
case EcaState.startPass:
state = serverStartPass + serverRunning
state = serverStartPass
case EcaState.finishPass:
state = serverFinishPass + serverRunning
state = serverFinishPass
case EcaState.end:
state = serverEnd + serverRunning
state = serverEnd
case EcaState.incomplete:
state = serverIncomplete
case EcaState.cancel:
......
......@@ -30,6 +30,8 @@ class AlertManager {
let content = UNMutableNotificationContent()
content.title = alertrec.title
content.body = alertrec.body
content.categoryIdentifier = "alarm"
content.userInfo = ["key": "map"]
content.sound = UNNotificationSound.default
// 「通知」を発生させる
......
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