Skip to content

Commit

Permalink
Fix readme (#119)
Browse files Browse the repository at this point in the history
* Fix readme

* Bump version to 0.3.4
  • Loading branch information
katayama8000 authored Jun 15, 2024
1 parent 0c02f78 commit 03b6f76
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "expo_push_notification_client"
version = "0.3.3"
version = "0.3.4"
edition = "2021"
readme = "README.md"
authors = ["katayama8000 <https://github.com/katayama8000>"]
Expand Down
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ cargo add expo_push_notification_client
### Usage

```rust
use expo_push_notification_client::{Expo, ExpoClientOptions, ExpoPushMessage, GetPushNotificationReceiptsRequest};
use expo_push_notification_client::{Expo, ExpoClientOptions, ExpoPushMessage};

// Initialize Expo client
let expo = Expo::new(ExpoClientOptions {
access_token: Some(access_token),
use_fcm_v1: Some(false), // Set to true to use FCM v1 API
..Default::default()
});

// Define Expo Push Tokens to send notifications to
Expand All @@ -38,10 +39,20 @@ let expo_push_tokens = ["ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]"];
let expo_push_message = ExpoPushMessage::builder(expo_push_tokens).build()?;

// Send push notifications using Expo client
expo.send_push_notifications(expo_push_message).await;

// Define push notification IDs to retrieve receipts
let expo_push_ids = GetPushNotificationReceiptsRequest::new(vec!["xxxxx".to_string(), "xxxxx".to_string()]);
let tickets = expo.send_push_notifications(expo_push_message).await;

// Extract push notification IDs from tickets
let mut expo_push_ids = vec![];
for ticket in tickets {
match ticket {
ExpoPushTicket::Ok(ticket) => {
expo_push_ids.push(ticket.id);
}
ExpoPushTicket::Error(e) => {
// Handle error
}
}
}

// Retrieve push notification receipts using Expo client
expo.get_push_notification_receipts(expo_push_ids).await;
Expand Down

0 comments on commit 03b6f76

Please sign in to comment.