Skip to content

1amageek/Tsuchi

 
 

Repository files navigation

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, contact@miup.blue

License

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

About

Firebase Cloud Messaging wrapper.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 81.8%
  • Ruby 18.2%