Commit 7d4ad639 authored by sugita mamoru's avatar sugita mamoru

Merge commit 'f436dc36' into develop

parents 07a61c4c f436dc36
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/AzureNotificationHubs-iOS FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SwiftSignalRClient" "${PODS_ROOT}/AzureNotificationHubs-iOS/WindowsAzureMessaging-SDK-Apple" "${PODS_XCFRAMEWORKS_BUILD_DIR}/AzureNotificationHubs-iOS"
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/AzureNotificationHubs-iOS/WindowsAzureMessaging-SDK-Apple" "${PODS_XCFRAMEWORKS_BUILD_DIR}/AzureNotificationHubs-iOS"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
OTHER_LDFLAGS = $(inherited) -framework "Foundation" -framework "SystemConfiguration" -framework "UIKit" -weak_framework "UserNotifications" HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SwiftSignalRClient/SwiftSignalRClient.framework/Headers"
OTHER_LDFLAGS = $(inherited) -framework "Foundation" -framework "SwiftSignalRClient" -framework "SystemConfiguration" -framework "UIKit" -weak_framework "UserNotifications"
PODS_BUILD_DIR = ${BUILD_DIR} PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_DEVELOPMENT_LANGUAGE = ${DEVELOPMENT_LANGUAGE} PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
PODS_ROOT = ${SRCROOT} PODS_ROOT = ${SRCROOT}/Pods
PODS_TARGET_SRCROOT = ${PODS_ROOT}/AzureNotificationHubs-iOS
PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
${PODS_ROOT}/Target Support Files/Pods-Sailassist/Pods-Sailassist-frameworks.sh
${BUILT_PRODUCTS_DIR}/SwiftSignalRClient/SwiftSignalRClient.framework
\ No newline at end of file
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftSignalRClient.framework
\ No newline at end of file
...@@ -175,7 +175,10 @@ code_sign_if_enabled() { ...@@ -175,7 +175,10 @@ code_sign_if_enabled() {
fi fi
} }
if [[ "$CONFIGURATION" == "Debug" ]]; then if [[ "$CONFIGURATION" == "Canary" ]]; then
install_framework "${BUILT_PRODUCTS_DIR}/SwiftSignalRClient/SwiftSignalRClient.framework"
fi
if [[ "$CONFIGURATION" == "QC" ]]; then
install_framework "${BUILT_PRODUCTS_DIR}/SwiftSignalRClient/SwiftSignalRClient.framework" install_framework "${BUILT_PRODUCTS_DIR}/SwiftSignalRClient/SwiftSignalRClient.framework"
fi fi
if [[ "$CONFIGURATION" == "Release" ]]; then if [[ "$CONFIGURATION" == "Release" ]]; then
......
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/SwiftSignalRClient FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SwiftSignalRClient" "${PODS_ROOT}/AzureNotificationHubs-iOS/WindowsAzureMessaging-SDK-Apple" "${PODS_XCFRAMEWORKS_BUILD_DIR}/AzureNotificationHubs-iOS"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SwiftSignalRClient/SwiftSignalRClient.framework/Headers"
LD_RUNPATH_SEARCH_PATHS = $(inherited) /usr/lib/swift '@executable_path/Frameworks' '@loader_path/Frameworks'
LIBRARY_SEARCH_PATHS = $(inherited) "${TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift LIBRARY_SEARCH_PATHS = $(inherited) "${TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift
OTHER_LDFLAGS = $(inherited) -ObjC -framework "Foundation" -framework "SwiftSignalRClient" -framework "SystemConfiguration" -framework "UIKit" -framework "WindowsAzureMessaging" -weak_framework "UserNotifications"
OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS
PODS_BUILD_DIR = ${BUILD_DIR} PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_DEVELOPMENT_LANGUAGE = ${DEVELOPMENT_LANGUAGE} PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
PODS_ROOT = ${SRCROOT} PODS_ROOT = ${SRCROOT}/Pods
PODS_TARGET_SRCROOT = ${PODS_ROOT}/SwiftSignalRClient
PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
shouldAutocreateTestPlan = "YES"> shouldAutocreateTestPlan = "YES">
</TestAction> </TestAction>
<LaunchAction <LaunchAction
buildConfiguration = "Debug" buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0" launchStyle = "0"
......
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "020B980F2AD8C3140029DE4C"
BuildableName = "Sailassist.app"
BlueprintName = "Sailassist"
ReferencedContainer = "container:Sailassist.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Canary"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Canary"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "020B980F2AD8C3140029DE4C"
BuildableName = "Sailassist.app"
BlueprintName = "Sailassist"
ReferencedContainer = "container:Sailassist.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "020B980F2AD8C3140029DE4C"
BuildableName = "Sailassist.app"
BlueprintName = "Sailassist"
ReferencedContainer = "container:Sailassist.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Canary">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "020B980F2AD8C3140029DE4C"
BuildableName = "Sailassist.app"
BlueprintName = "Sailassist"
ReferencedContainer = "container:Sailassist.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Canary"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "QC"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "020B980F2AD8C3140029DE4C"
BuildableName = "Sailassist.app"
BlueprintName = "Sailassist"
ReferencedContainer = "container:Sailassist.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "020B980F2AD8C3140029DE4C"
BuildableName = "Sailassist.app"
BlueprintName = "Sailassist"
ReferencedContainer = "container:Sailassist.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Canary">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Canary.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>3</integer>
</dict>
<key>QC.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>5</integer>
</dict>
<key>Sailassist.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>4</integer>
</dict>
</dict>
</dict>
</plist>
//
// AlertDB.swift
// Sailassist
//
// Created by 三浦薫巳 on 2023/11/19.
//
import Foundation
struct WarnRecord {
var title: String
var body: String
let soundName: String
}
enum SwitchingEca {
case Finish
case Start
case Notice
init() {
self = .Notice
}
}
class AlertDB {
// シングルトン宣言
static let OnlyOne = AlertDB()
private var alertEca : [SwitchingEca: WarnRecord] = [
SwitchingEca.Finish: WarnRecord(title: NSLocalizedString("Eca Finish", comment: ""), body: NSLocalizedString("Arrived at switching finished point", comment: ""), soundName: "sound_eca.mp3")
, SwitchingEca.Start: WarnRecord(title: NSLocalizedString("Eca Start", comment: ""), body: NSLocalizedString("Arrivaed at switching start point", comment: ""), soundName: "sound_eca.mp3")
, SwitchingEca.Notice: WarnRecord(title: NSLocalizedString("Eca Notice", comment: ""), body: NSLocalizedString("Arrived at advance notice point", comment: ""), soundName: "sound_eca.mp3")
]
//Eca通知
func GetAlertEcaPoint(point : SwitchingEca) -> WarnRecord {
return alertEca[point]!
}
}
//
// PushNotificationTypes.swift
// Sailassist
//
// Created by 三浦薫巳 on 2023/11/19.
//
import Foundation
struct PushNotificationTypes {
//リモートPush用sendType
enum SendType: Int32{
case Error = -1
case Eca = 0 // Eca
init(){
self = .Error
}
init?(_ code : Int32) {
switch code {
case 0: self = .Eca
default: self = .Error
}
}
}
//ローカルPush用Identifier
enum LocalPushIdentifier: String{
case Reserve = "Reserve" // 予約(初期設定)
case EcaSwitching = "Eca" // Eca
}
}
...@@ -16,6 +16,21 @@ class EcaTask { ...@@ -16,6 +16,21 @@ class EcaTask {
sessionShipStatus.RequestShipStatus(responseShipStatus) sessionShipStatus.RequestShipStatus(responseShipStatus)
} }
/**
* Eca通知
*/
private func notificationEca(point: SwitchingEca) {
let alertDB = AlertDB.OnlyOne
var wernrec = WarnRecord(title:"Eca", body:"", soundName:"")
wernrec = alertDB.GetAlertEcaPoint(point: point)
let formatstr = wernrec.title
wernrec.title = String(format: formatstr)
let voicemanager = AlertManager.OnlyOne
voicemanager.VocalizeAlert(alertrec: wernrec, identifier: .EcaSwitching)
}
func responseShipStatus(result: Result<Data, APIError>) { func responseShipStatus(result: Result<Data, APIError>) {
print(debug: "called") print(debug: "called")
switch result { switch result {
...@@ -29,6 +44,10 @@ class EcaTask { ...@@ -29,6 +44,10 @@ class EcaTask {
SharingData.my.server?.latitude = res.lat SharingData.my.server?.latitude = res.lat
SharingData.my.server?.longitude = res.lon SharingData.my.server?.longitude = res.lon
SharingData.my.dataTime = res.dataTime //2023-11-02T05:25:49.4362123Z SharingData.my.dataTime = res.dataTime //2023-11-02T05:25:49.4362123Z
if Preferences.LocationType == 1 {
SharingData.my.location = SharingData.my.server
}
} }
checkEca() checkEca()
case .failure(let errorCode): case .failure(let errorCode):
...@@ -37,20 +56,20 @@ class EcaTask { ...@@ -37,20 +56,20 @@ class EcaTask {
} }
} }
private func checkEca() { func checkEca() {
let runningEca = eca.ecaArea.first(where: {(key, value) in value.isRunning == true}) let runningEca = eca.ecaArea.first(where: {(key, value) in value.isRunning == true})
if let eca = runningEca?.value { if let eca = runningEca?.value {
if let location = SharingData.my.location { if let location = SharingData.my.location {
let distance = LocationCalculation.checkPolyLine(objPos: eca.points, shipPos: location) let distance = LocationCalculation.checkPolyLine(objPos: eca.points, shipPos: location)
if eca.swStart >= Float(distance) { if eca.swStart >= Float(distance) {
notificationEca(point: SwitchingEca.Start)
} }
if eca.swNotice >= Float(distance) { if eca.swNotice >= Float(distance) {
notificationEca(point: SwitchingEca.Notice)
} }
if eca.swFinish >= Float(distance) { if eca.swFinish >= Float(distance) {
notificationEca(point: SwitchingEca.Finish)
} }
} }
} }
......
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
import Foundation import Foundation
// TODO: サイトのアドレスを変更 // TODO: サイトのアドレスを変更
#if DEBUG #if CANARY
//MARK: デバッグサーバー用
enum HttpRequestType : String { enum HttpRequestType : String {
case RegisterLogin = "https://ssv-canary-web.azurewebsites.net/sailassistlogin" case RegisterLogin = "https://ssv-canary-web.azurewebsites.net/sailassistlogin"
case SitePolicy = "https://ssv-canary-web.azurewebsites.net/sitepolicy" case SitePolicy = "https://ssv-canary-web.azurewebsites.net/sitepolicy"
...@@ -22,13 +21,40 @@ enum HttpRequestType : String { ...@@ -22,13 +21,40 @@ enum HttpRequestType : String {
case GetMessage = "https://ssv-canary-web.azurewebsites.net/api/chatdata/getmessages?shipId=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 SignalR = "https://ssv-canary-web.azurewebsites.net/signalr/shore"
case UploadImage = "https://ssv-canary-web.azurewebsites.net/api/chatdata/uploadimage" case UploadImage = "https://ssv-canary-web.azurewebsites.net/api/chatdata/uploadimage"
case ConnectionString = "Endpoint=sb://ssv-canary-notification.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=rj2WniCJWWP2SG5gk4J7/2P/nIyChx8+JXKWCfTi8KA="
case HubName = "ssv-canary-notification"
}
#elseif QC
enum HttpRequestType : String {
case RegisterLogin = "https://ssv-qc-web.azurewebsites.net/sailassistlogin"
case SitePolicy = "https://ssv-qc-web.azurewebsites.net/sitepolicy"
case CookiePolicy = "https://ssv-qc-web.azurewebsites.net/cookiepolicy"
case PrivacyPolicy = "https://ssv-qc-web.azurewebsites.net/inapp?" //+バージョン番号
case TaskList = "https://ssv-qc-web.azurewebsites.net/api/sailassist/tasklist/XXXXX"
case EcaArea = "https://ssv-qc-web.azurewebsites.net/api/sailassist/ecaarea"
case ShipStatus = "https://ssv-qc-web.azurewebsites.net/api/sailassist/shipstatus/XXXXX"
case ShipMonitoringRoute = "https://ssv-qc-web.azurewebsites.net/api/sailassist/shipmonitoringroute/XXXXX"
case GetMessage = "https://ssv-qc-web.azurewebsites.net/api/chatdata/getmessages?shipId=XXXXX"
case SignalR = "https://ssv-qc-web.azurewebsites.net/signalr/shore"
case UploadImage = "https://ssv-qc-web.azurewebsites.net/api/chatdata/uploadimage"
case ConnectionString = "Endpoint=sb://tacmiqchub.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=mjGZyOensA5D/T6bMiDDwX6hwhoZNsDcK+GtBBBiUXk="
case HubName = "tacmiqchub"
} }
#else #else
//MARK: 運用サーバー用 //MARK: 運用サーバー用
enum HttpRequestType : String { enum HttpRequestType : String {
case RegisterLogin = "https://ssv.jmarinecloud.com/applogin" case RegisterLogin = "https://ssv.jmarinecloud.com/sailassistlogin"
case SitePolicy = "https://ssv.jmarinecloud.com/sitepolicy" case SitePolicy = "https://ssv.jmarinecloud.com/sitepolicy"
case CookiePolicy = "https://ssv.jmarinecloud.com/cookiepolicy" case CookiePolicy = "https://ssv.jmarinecloud.com/cookiepolicy"
case PrivacyPolicy = "https://ssv.jmarinecloud.com/inapp?" 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 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"
} }
#endif #endif
...@@ -6,7 +6,9 @@ ...@@ -6,7 +6,9 @@
<string>pk.eyJ1Ijoiam1hcmluZWNsb3VkIiwiYSI6ImNsbmxjbGYzZjA0dG8yaW82MDgwajQ5OTQifQ.pd8YC9qK1C4YmMUbMx6ywQ</string> <string>pk.eyJ1Ijoiam1hcmluZWNsb3VkIiwiYSI6ImNsbmxjbGYzZjA0dG8yaW82MDgwajQ5OTQifQ.pd8YC9qK1C4YmMUbMx6ywQ</string>
<key>UIBackgroundModes</key> <key>UIBackgroundModes</key>
<array> <array>
<string>audio</string>
<string>location</string> <string>location</string>
<string>remote-notification</string>
</array> </array>
</dict> </dict>
</plist> </plist>
...@@ -40,9 +40,14 @@ class LocationViewModel: NSObject, ObservableObject, CLLocationManagerDelegate { ...@@ -40,9 +40,14 @@ class LocationViewModel: NSObject, ObservableObject, CLLocationManagerDelegate {
if let newLocation = locations.last { if let newLocation = locations.last {
let isLocation = filterLocation(newLocation) let isLocation = filterLocation(newLocation)
if isLocation { if isLocation {
lastSeenLocation = locations.first lastSeenLocation = locations.first
let targetCoordinate : CLLocationCoordinate2D = lastSeenLocation!.coordinate let targetCoordinate : CLLocationCoordinate2D = lastSeenLocation!.coordinate
SharingData.my.gps = targetCoordinate SharingData.my.gps = targetCoordinate
if Preferences.LocationType == 0 {
SharingData.my.location = SharingData.my.gps
let ecaTask = EcaTask()
ecaTask.checkEca()
}
} }
} }
} }
......
...@@ -26,8 +26,10 @@ class Preferences{ ...@@ -26,8 +26,10 @@ class Preferences{
@AppStorage(wrappedValue:"", PreferencesKey.TypeString.ShipId.rawValue) static var ShipId: String @AppStorage(wrappedValue:"", PreferencesKey.TypeString.ShipId.rawValue) static var ShipId: String
@AppStorage(wrappedValue:"", PreferencesKey.TypeString.ShipPassword.rawValue) static var ShipPassword: String @AppStorage(wrappedValue:"", PreferencesKey.TypeString.ShipPassword.rawValue) static var ShipPassword: String
@AppStorage(wrappedValue:"", PreferencesKey.TypeString.UserName.rawValue) static var UserName: String @AppStorage(wrappedValue:"", PreferencesKey.TypeString.UserName.rawValue) static var UserName: String
// func getPreferences(key)
@AppStorage(wrappedValue:0, PreferencesKey.TypeInt.LocationType.rawValue) static var LocationType: Int
// func getPreferences(key)
@AppStorage(PreferencesKey.TypeURL.ECDIS.rawValue) static var ECDISUrl: URL? @AppStorage(PreferencesKey.TypeURL.ECDIS.rawValue) static var ECDISUrl: URL?
} }
......
...@@ -19,9 +19,9 @@ class PreferencesKey{ ...@@ -19,9 +19,9 @@ class PreferencesKey{
///Int型 ///Int型
enum TypeInt: String{ enum TypeInt: String{
case LocationType
case AppStartUsingDate case AppStartUsingDate
case LastLoginDate case LastLoginDate
} }
enum TypeURL: String{ enum TypeURL: String{
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
</dict>
</plist>
...@@ -6,10 +6,13 @@ ...@@ -6,10 +6,13 @@
// //
import SwiftUI import SwiftUI
import UserNotifications
import WindowsAzureMessaging
@main @main
struct SailassistApp: App { struct SailassistApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) private var delegate @UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
var body: some Scene { var body: some Scene {
WindowGroup { WindowGroup {
ContentView() ContentView()
...@@ -18,11 +21,67 @@ struct SailassistApp: App { ...@@ -18,11 +21,67 @@ struct SailassistApp: App {
} }
class AppDelegate: NSObject, UIApplicationDelegate{ class AppDelegate: NSObject, UIApplicationDelegate{
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
print(debug: "called")
//プッシュ通知の利用許可のリクエスト送信
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in
if error != nil {
return
}
if granted {
UNUserNotificationCenter.current().delegate = self
}
}
application.registerForRemoteNotifications()
MSNotificationHub.start(connectionString: HttpRequestType.ConnectionString.rawValue, hubName: HttpRequestType.HubName.rawValue)
return true
}
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
print(debug: "called")
let config = UISceneConfiguration(name: nil, sessionRole: connectingSceneSession.role) let config = UISceneConfiguration(name: nil, sessionRole: connectingSceneSession.role)
config.delegateClass = SceneDelegate.self config.delegateClass = SceneDelegate.self
return config return config
} }
func notificationHub(_ notificationHub: MSNotificationHub!, didReceivePushNotification notification: MSNotificationHubMessage!) {
let title = notification.title ?? ""
let body = notification.body ?? ""
if (UIApplication.shared.applicationState == .background) {
print("Notification received in background: title:\"\(title)\" body:\"\(body)\"")
} else {
let alertController = UIAlertController(title: title, message: body, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "OK", style: .cancel))
// self.present(alertController, animated: true)
}
}
}
extension AppDelegate: UNUserNotificationCenterDelegate {
// フォアグラウンド状態で通知を受信して表示する
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo
print(debug: userInfo)
completionHandler([[.banner, .badge, .sound]])
}
// バックグラウンド状態で通知を受信して表示する
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
print(debug: userInfo)
completionHandler()
}
} }
class SceneDelegate: UIResponder, UIWindowSceneDelegate, ObservableObject { class SceneDelegate: UIResponder, UIWindowSceneDelegate, ObservableObject {
......
//
// SignalRService.swift
// Sailassist
//
// Created by 三浦薫巳 on 2023/11/17.
//
import Foundation
import SwiftSignalRClient
public class SignalRService {
private var connection: HubConnection
public init(url: URL) {
// リクエストURLの組み立て
// let url_string : String = HttpRequestType.SignalR.rawValue
// guard let req_url = URL(string : url_string) else {
// return
// }
connection = HubConnectionBuilder(url: url).withLogging(minLogLevel: .error).build()
connection.on(method: "MessageReceived", callback: { (user: String, message: String) in
do {
self.handleMessage(message, from: user)
} catch {
print(error)
}
})
// hubConnection?.invoke(method: "Your Method Name", arguments: [arg1, arg2]) { error in
// if let error = error {
// print("An error occurred: %@", "\(error)")
// }
// }
//
// hubConnection?.on(method: "YourMethod", callback: { (chatCount: Int, notificationsCount: Int) in
// self.notificationCount = notificationsCount
// self.chatCount = chatCount
// })
connection.start()
}
private func handleMessage(_ message: String, from user: String) {
// Do something with the message.
}
func connectionDidOpen(hubConnection: SwiftSignalRClient.HubConnection) {
print("connectionDidOpen")
// After connection established call registerUserInServer method
DispatchQueue.main.async {
// self.registerUserInServer()
}
}
func connectionDidFailToOpen(error: Error) {
print("connectionDidFailToOpen")
}
func connectionDidClose(error: Error?) {
print("connectionDidClose")
}
func connectionWillReconnect(error: Error) {
print("connectionWillReconnect")
}
func connectionDidReconnect() {
print("connectionDidReconnect")
}
}
//
// AlertManager.swift
// Sailassist
//
// Created by 三浦薫巳 on 2023/11/19.
//
import Foundation
import UIKit
import AVFoundation
// 音声を扱うクラスのうち、アラートに関するもの
class AlertManager {
// シングルトン宣言
static let OnlyOne = AlertManager()
private var player: AVAudioPlayer! // ここでインスタンスを作ると例外発生
var lastAlert: PushNotificationTypes.LocalPushIdentifier = .Reserve
var lastSpeech: String = ""
private init() {
//とりあえず音源を仮で置いておく
let soundpath = Bundle.main.bundleURL.appendingPathComponent("no_sound.mp3")
do {
player = try AVAudioPlayer(contentsOf: soundpath)
} catch {
}
}
// 無音を鳴らす
func PlayNoSound( identifier : String ) {
let content = "no_sound.mp3"
lastSpeech = identifier
let soundpath = Bundle.main.bundleURL.appendingPathComponent(content)
do {
if(player.isPlaying){
print(debug: "SOUND Playing: \(content)")
//再生中の音を止めてしてしまうので再生しない
} else {
player = try AVAudioPlayer(contentsOf: soundpath)
player.play()
print(debug: "SOUND Go play: \(content)")
}
} catch {
lastSpeech = ""
print(debug: "SOUND NoSound: \(content)")
return
}
}
// 音声だけ鳴らす
func Speaking( identifier : String, content : String ) {
lastSpeech = identifier
// 音声を再生する
let soundpath = Bundle.main.bundleURL.appendingPathComponent(content)
do {
player = try AVAudioPlayer(contentsOf: soundpath)
player.play()
print(debug: "SOUND Go play: \(content)")
} catch {
lastSpeech = ""
print(debug: "SOUND NoSound: \(content)")
return
}
}
// 音声再生中止
func CancelSpeak( identifier : String ) {
if let alertPlayer = player {
if alertPlayer.isPlaying == true {
if lastSpeech == identifier {
alertPlayer.stop()
}
}
}
lastSpeech = ""
}
// 警報を鳴らす。引数の型定義はAlertDB.swift
func VocalizeAlert( alertrec : WarnRecord ) {
VocalizeAlert( alertrec: alertrec, identifier: .EcaSwitching)
}
func VocalizeAlert( alertrec : WarnRecord, identifier : PushNotificationTypes.LocalPushIdentifier ) {
print(debug: "alertrec = \(alertrec)")
// 警報を通知する
let content = UNMutableNotificationContent()
content.title = alertrec.title
content.body = alertrec.body
/* 「通知」側の音声は、再生時間上限(10sec)の関係で無音とする
* 無音声ファイル(no_sound.mp3)は予め AppDelegateで ${App}/Library/Sounds にコピー済み
*/
content.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: "no_sound.mp3"))
// 「通知」を発生させる
let request = UNNotificationRequest( identifier: identifier.rawValue, content: content, trigger: nil )
// let request = UNNotificationRequest( identifier: "ShipWarn", content: content, trigger: nil )
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
lastAlert = identifier
// 音声を再生する
let soundpath = Bundle.main.bundleURL.appendingPathComponent(alertrec.soundName)
do {
player = try AVAudioPlayer(contentsOf: soundpath)
player.play()
print(debug: "SOUND Go play: \(alertrec.soundName)")
} catch {
lastAlert = .Reserve
print(debug: "SOUND NoSound: \(alertrec.soundName)")
return
}
}
// 警報の再生を中断する
func CancelAlert() {
CancelAlert(identifier : .EcaSwitching )
}
// 警報の再生を中断する
func CancelAlert( identifier : PushNotificationTypes.LocalPushIdentifier ) {
if let alertPlayer = player {
if alertPlayer.isPlaying == true {
if lastAlert == identifier {
alertPlayer.stop()
}
}
}
lastAlert = .Reserve
}
}
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