Skip to content

Releases: MihaelIsaev/FCM

⚡️Swift 6 and async/await

11 Nov 16:59
Compare
Choose a tag to compare
Pre-release

Many thanks to @gennaro-safehill and @ptoffy for their great contributions!

FCM now supports Swift 6 and async/await!

All the details are in the updated readme

This is a pre-release version, so use it carefully in production.

@ptoffy will test it in staging/production environments before we tag it as a stable release.

Please share your feedback!

Add method to retrieve subscribed topics

14 Mar 22:44
3414d98
Compare
Choose a tag to compare

Add image for the push notifications

14 Mar 14:21
cbc8255
Compare
Choose a tag to compare

FCMApnsConfig initializer now have optional FCMOptions argument which could be used to attach image to the push notification.

Thanks to @paunik

Fix memory issues (#26) by @grahamburgsma

12 Aug 09:57
919d41a
Compare
Choose a tag to compare
  • Use Vapor client instead to get helpers and reduce lower level work
  • Update all other uses of client
  • Generalize response error handling

Implement one more convenient initialization

23 May 19:02
Compare
Choose a tag to compare
app.fcm.configuration = .envServiceAccountKeyFields

it will initialize FCM by reading the following environment variables

FCM_EMAIL - `client_email` in service.json
FCM_PROJECT_ID - `project_id` in service.json
FCM_PRIVATE_KEY - `private_key` in service.json

☄️ Implement batch sending

16 May 00:31
Compare
Choose a tag to compare
// get it from iOS/Android SDK
let token1 = "<YOUR FIREBASE DEVICE TOKEN>"
let token2 = "<YOUR FIREBASE DEVICE TOKEN>"
let token3 = "<YOUR FIREBASE DEVICE TOKEN>"
...
let token100500 = "<YOUR FIREBASE DEVICE TOKEN>"

let notification = FCMNotification(title: "Life is great! 😃", body: "Swift one love! ❤️")
let message = FCMMessage(notification: notification)
application.fcm.batchSend(message, tokens: [token1, token2, token3, ..., token100500]).map {
    print("sent!")
}

🔥 Implement pure APNS to Firebase token converter

15 May 14:40
Compare
Choose a tag to compare

Now you can throw away Firebase libs from dependencies of your iOS apps because you can send pure APNS tokens to your server and it will register it in Firebase by itself.

It is must have for developers who don't want to add Firebase libs into their apps, and especially for iOS projects who use Swift Package Manager cause Firebase doesn't have SPM support for its libs yet.

How to use

Preparation

  1. Go to Firebase Console -> Project Settings -> Cloud Messaging tab
  2. Copy Server Key from Project Credentials area

Next steps are optional

  1. Put server key into environment variables as FCM_SERVER_KEY=<YOUR_SERVER_KEY>
  2. Put your app bundle identifier into environment variables as FCM_APP_BUNDLE_ID=<APP_BUNDLE_ID>

Tokens registration

/// The simplest way
/// .env here means that FCM_SERVER_KEY and FCM_APP_BUNDLE_ID will be used
application.fcm.registerAPNS(.env, tokens: "token1", "token3", ..., "token100").flatMap { tokens in
    /// `tokens` is array of `APNSToFirebaseToken` structs
    /// which contains:
    /// registration_token - Firebase token
    /// apns_token - APNS token
    /// isRegistered - boolean value which indicates if registration was successful
}

/// instead of .env you could declare your own identifier
extension RegisterAPNSID {
   static var myApp: RegisterAPNSID { .init(appBundleId: "com.myapp") }
}

/// Advanced way
application.fcm.registerAPNS(
    appBundleId: String, // iOS app bundle identifier
    serverKey: String?, // optional server key, if nil then env variable will be used
    sandbox: Bool, // optional sandbox key, false by default
    tokens: [String], // an array of APNS tokens
    on: EventLoop? // optional event loop, if nil then application.eventLoopGroup.next() will be used
).flatMap { tokens in
    /// the same as in above example
}

Fix annoying moments

23 Feb 11:11
Compare
Choose a tag to compare
  • fix annoying warning: cannot modify client configuration after client has been used
  • add send method with eventLoop argument to avoid manual hop(to:) call
    so now if you send from Request you could write
req.fcm.send(message, on: req.eventLoop)

instead of

req.fcm.send(message).hop(to: req.eventLoop)

New properties for `FCMAndroidNotification` (#18)

05 Jan 23:09
Compare
Choose a tag to compare

Vapor 4 🚀

05 Jan 18:25
Compare
Choose a tag to compare

Please read the readme to get all the details