Tsuchi is awesome Firebase Cloud Messaging wrapper.
You can handle FCM easily and type-safely.
User.login {
// register remote notification (show dialog if user not determined about notification permission.)
Tsuchi.shared.register { authorized in
//...
}
}
User.logout {
Tsuchi.shared.unregister { authorized in
//...
}
}
-
- Create Payload Model (must conform to
PushNotificationPayload
)
- Create Payload Model (must conform to
struct FCMNotificationPayload: PushNotificationPayload {
let eventName: String?
let eventType: EventType?
var aps: APS?
}
-
- call
Tsuchi.subscibe(_:completion)
- call
Tsuchi.shared.subscribe(FCMNotificationPayload.self) { result in
switch result {
case .success(let (notification, mode)):
print(notification.name, mode)
case .failure(let error):
print(error)
}
}
public enum AppTopic: String, TopicType {
case owner
case member
}
// Subscribe topic
Tsuchi.shared.subscribe(toTopic: AppTopic.owner)
// Unsubscribe topic
Tsuchi.shared.unsubscribe(fromTopic: AppTopic.owner)
To run the example project, clone the repo, and run pod install
from the Example directory first.
Tsuchi is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Tsuchi'
miup, [email protected]
Tsuchi is available under the MIT license. See the LICENSE file for more info.