Skip to content

Commit bc5b188

Browse files
authored
Merge pull request #4 from devwaseem/add_readme
Update README.md
2 parents 6e01f75 + 6d28be2 commit bc5b188

File tree

1 file changed

+107
-7
lines changed

1 file changed

+107
-7
lines changed

README.md

Lines changed: 107 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@
2626
- Add `https://github.com/devwaseem/MailTMSwift.git`
2727
- Select "Up to Next Major" with "1.1.1"
2828

29-
## Supported platforms
30-
| Platform | Supported versions |
31-
| -------- | ------------------ |
32-
| iOS | 11+ |
33-
| MacOS | 10.12+ |
34-
| watchOS | 4+ |
35-
| tvOS | 11+ |
29+
## Requirements
30+
31+
Swift: 5.0
32+
33+
| Platform | Minimum required version |
34+
| -------- | ------------------------ |
35+
| iOS | 11.0 |
36+
| macOS | 10.12 |
37+
| watchOS | 4.0 |
38+
| tvOS | 11.0 |
3639

3740
## Highlights
3841
🕹 Simple interface
@@ -246,6 +249,103 @@ messageService.deleteMessage(id: id, token: token) { (result: Result<MTEmptyResu
246249
}
247250
```
248251

252+
## 🚥 Live Events
253+
254+
[`MTLiveMailService`](https://mailtmswift.waseem.works/documentation/mailtmswift/mtlivemailservice) uses Apple's Combine framework to listen for live events. Make sure you use the required minimum version of the platform you're using this package.
255+
256+
>
257+
258+
### Setup
259+
260+
```swift
261+
import MailTMSwift
262+
import Combine
263+
264+
let subscriptions = Set<AnyCancellable>()
265+
let token = // Account JWT token
266+
let id = // Account id
267+
let liveMailService = MTLiveMailService(token: token, accountId: id)
268+
```
269+
270+
### Listen for New / Updated messages
271+
272+
```swift
273+
liveMailService.messagePublisher.sink { message in
274+
print("Received message event: \(message)")
275+
}
276+
.store(in: &subscriptions)
277+
```
278+
279+
### Listen for account updates
280+
281+
```swift
282+
liveMailService.accountPublisher.sink { account in
283+
print("Received account event: \(account)")
284+
}
285+
.store(in: &subscriptions)
286+
```
287+
288+
### Listen for connection changes
289+
290+
```swift
291+
liveMailService.statePublisher.sink { state in
292+
if state == .opened {
293+
print("Connected to server")
294+
} else {
295+
print("Disconnected to server")
296+
}
297+
}
298+
.store(in: &subscriptions)
299+
```
300+
301+
### Start the listener
302+
303+
```swift
304+
liveMailService.start()
305+
```
306+
307+
### Stop the listener
308+
309+
```swift
310+
liveMailService.stop()
311+
```
312+
313+
### Restart the listener
314+
315+
```swift
316+
liveMailService.restart()
317+
```
318+
319+
Enable `autoRetry` property to automatically restart the connection if the connection is lost in between.
320+
321+
```swift
322+
liveMailService.autoRetry = true
323+
```
324+
325+
## Contribute 🤝
326+
327+
If you want to contribute to this library, you're always welcome!
328+
You can contribute by filing issues, bugs and PRs.
329+
330+
### Contributing guidelines:
331+
- Open issue regarding proposed change.
332+
- Repo owner will contact you there.
333+
- If your proposed change is approved, Fork this repo and do changes.
334+
- Open PR against latest `development` branch. Add nice description in PR.
335+
- You're done!
336+
337+
## ☕️ Donation
338+
339+
If this project helped you in any way, you can give me a cup of coffee :).
340+
341+
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.me/iamwaseem99)
342+
343+
## 📱 Contact
344+
345+
Have an project? DM us at 👇
346+
347+
Drop a mail to:- waseem07799@gmail.com
348+
249349
## License
250350

251351
MailTMSwift is released under the MIT license. See [LICENSE](https://raw.githubusercontent.com/devwaseem/MailTMSwift/main/LICENSE) for details.

0 commit comments

Comments
 (0)