<aside> 🔨 NEXTERS 15기 프로젝트 [팀 구성] 8인 (Server 2, Android 2, iOS 2, Designer 2)
</aside>
[2019. 06 ~ 2019. 08]
감정기록 앱 서비스 '찰랑말랑' (출시 완료)https://s3-us-west-2.amazonaws.com/secure.notion-static.com/8250c19d-64bb-4747-9143-474423c14606/lottieSpeed4.mp4
TroubleShooting
<aside> 💡 기획이 명확해질 쯤 다이어리 성향이 강한 서비스에 과연 서버가 필요할까? 라는 의문점이 재기됨. (여타 다이어리 앱은 로그인 기능이 없고, 오프라인 상태에서도 이용할 수 있음) 그래서 서로가 학술적인 의미로 서버(온라인)를 가져가되, 오프라인에서도 불편함 없이 사용이 가능하도록 구현을 하자! 라는 의견으로 모아짐. 약 1~2주 간의 논의를 마친 뒤 나온 결론이 OfflineQueue를 클라이언트에서 만들어 오프라인 상태에서도 유저에게 마치 서비스가 잘 돌아가는 것 처럼(온라인 상태인 것 처럼) 보이게 하여 해결함.
OfflineQueue의 Flow는 다음과 같다. didFinishLaunchingWithOptions(앱 실행 시) 에서는 UserDefaults에 저장된 OfflineQueue를 불러오고, applicationWillTerminate(앱 종료 시) 에서는 OfflineQueue를 UserDefaults에 저장한다.
먼저 메인화면에서 viewDidLoad를 통해 해당 유저가 작성한 데이터를 caching하여 갖고 있는다. 1-1. 이 때, 인터넷 연결이 되어 있지 않다면 데이터를 가져올 수 없다는 알림을 띄워준다.
다음 유저가 감정을 작성하는 화면에서 완료를 눌렀을 시점에 인터넷 연결 상태를 체크한다. (서버에 요청을 보내고 response를 기다리기엔 시간이 소요되므로) 2-1(연결이 되어 있지 않은 경우). OfflineQueue에 작성된 post를 append 시킨다. 2-2-1(연결이 되어 있는 경우). OfflineQueue가 비어있는지 확인 후, post가 있다면 먼저 request를 보낸다. 2-2-2. request가 완료되면 OfflineQueue를 비운다. 2-3. 2에서 작성 된 post를 request 한다.
다음 화면인 List 뷰에서 OfflineQueue가 empty가 아닐 경우 caching한 데이터에 append 시켜 collectionView에 띄워준다 (온라인데이터 + 오프라인데이터)
</aside>
Lottie 사용법
Networking
Push 알림 및 특정 view 로 redirect
Push 허용 상태에 따른 Push 설정 App 전환
let current = UNUserNotificationCenter.current()
guard let settingsUrl = NSURL(string:UIApplication.openSettingsURLString) as? URL else {return}
UIApplication.shared.open(settingsUrl, options: [:], completionHandler: nil)
// authorizationStatus 에 따른 분기
current.getNotificationSettings(completionHandler: { (settings) in
if settings.authorizationStatus == .notDetermined {
} else if settings.authorizationStatus == .denied {
} else if settings.authorizationStatus == .authorized {
}
})
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
/*
userInfo 에 data가 NSDictionary 형태로 담겨서 오며
Android는 data 구조체에 담겨져 오지만 iOS 는 Notification 에 담겨져 오는걸로 기억함. 다시 조사해보길.
*/
}