-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
SharedFunctions.swift
60 lines (48 loc) · 1.51 KB
/
SharedFunctions.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import Appboy_iOS_SDK
import Library
import UIKit
// MARK: - Haptic feedback
func generateImpactFeedback(
feedbackGenerator: UIImpactFeedbackGeneratorType = UIImpactFeedbackGenerator(style: .light)
) {
feedbackGenerator.prepare()
feedbackGenerator.impactOccurred()
}
func generateNotificationSuccessFeedback(
feedbackGenerator: UINotificationFeedbackGeneratorType = UINotificationFeedbackGenerator()
) {
feedbackGenerator.prepare()
feedbackGenerator.notificationOccurred(.success)
}
func generateNotificationWarningFeedback(
feedbackGenerator: UINotificationFeedbackGeneratorType = UINotificationFeedbackGenerator()
) {
feedbackGenerator.prepare()
feedbackGenerator.notificationOccurred(.warning)
}
func generateSelectionFeedback(
feedbackGenerator: UISelectionFeedbackGeneratorType = UISelectionFeedbackGenerator()
) {
feedbackGenerator.prepare()
feedbackGenerator.selectionChanged()
}
// MARK: - Login workflow
public func logoutAndDismiss(
viewController: UIViewController,
appEnvironment: AppEnvironmentType.Type = AppEnvironment.self,
pushNotificationDialog: PushNotificationDialogType.Type =
PushNotificationDialog.self
) {
appEnvironment.logout()
pushNotificationDialog.resetAllContexts()
NotificationCenter.default.post(.init(name: .ksr_sessionEnded))
viewController.dismiss(animated: true, completion: nil)
}
// MARK: - Braze
public func userNotificationCenterDidReceiveResponse(
appBoy: AppboyType?,
isNotNil: () -> (),
isNil: () -> ()
) {
appBoy == nil ? isNil() : isNotNil()
}