Tsuchi 0.8.0

Tsuchi 0.8.0

Maintained by miup.



 
Depends on:
Firebase/Core~> 8.3.0
Firebase/Messaging~> 8.3.0
 

Tsuchi 0.8.0

  • By
  • miup

Tsuchi

Tsuchi is awesome Firebase Cloud Messaging wrapper.
You can handle FCM easily and type-safely.

CI Status Version License Platform

Usage

Register/Unregister Notification

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
        //...
    }
}

Subscribe Push Notification

    1. Create Payload Model (must conform to PushNotificationPayload)
struct FCMNotificationPayload: PushNotificationPayload {
    let eventName: String?
    let eventType: EventType?
    var aps: APS?
}
    1. call Tsuchi.subscibe(_:completion)
Tsuchi.shared.subscribe(FCMNotificationPayload.self) { result in
    switch result {
    case .success(let (notification, mode)):
        print(notification.name, mode)
    case .failure(let error):
        print(error)
    }
}

Subscribe/UnSubscribe Topic

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)

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

Tsuchi is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Tsuchi'

Author

miup, [email protected]

License

Tsuchi is available under the MIT license. See the LICENSE file for more info.