MihaelIsaev / FCM

⚡️ PushNotifications through FireBase for Vapor 3 and 4.
MIT License
120 stars 33 forks source link

Swift 5.2.1 Support #32

Closed JCTec closed 3 years ago

JCTec commented 3 years ago

When updating to version 2.10.0 a compile error was introduce on file FCM/Sources/FCM/Helpers/FCM+BatchSend.swift although updating to Swift 5.3 fixes the issue, the 5.2.1 version is relatively new and the fix to make it compatible is minimal.

it will be to insert 2 self. in the return statement of _send(_ message: FCMMessageDefault, tokens: [String]) -> EventLoopFuture<[String]> to.

// Before

return getAccessToken().flatMap { accessToken in
    tokens.chunked(into: 500).map { chunk in
        _sendChunk(
            message,
            tokens: chunk,
            urlPath: urlPath,
            accessToken: accessToken
        )
    }
    .flatten(on: client.eventLoop)
    .map { $0.flatMap { $0 } }
}

// After

return getAccessToken().flatMap { accessToken in
    tokens.chunked(into: 500).map { chunk in
        self._sendChunk(
            message,
            tokens: chunk,
            urlPath: urlPath,
            accessToken: accessToken
        )
    }
    .flatten(on: self.client.eventLoop)
    .map { $0.flatMap { $0 } }
}