Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Every SDK requires authentication via API keys. Two key types are available:
> **Warning:** Store your API keys in environment variables or a secrets manager. Never commit them to source control.

```rust
use onesignal::apis::configuration::Configuration;
use onesignal_rust_api::apis::configuration::Configuration;

fn create_configuration() -> Configuration {
let mut config = Configuration::new();
Expand All @@ -40,13 +40,14 @@ fn create_configuration() -> Configuration {
## Send a push notification

```rust
use onesignal::apis::default_api;
use onesignal::models::{Notification, StringMap};
use onesignal_rust_api::apis::default_api;
use onesignal_rust_api::models::{Notification, LanguageStringMap};
use onesignal_rust_api::models::notification::TargetChannelType;

let mut contents = StringMap::new();
let mut contents = LanguageStringMap::new();
contents.en = Some("Hello from OneSignal!".to_string());

let mut headings = StringMap::new();
let mut headings = LanguageStringMap::new();
headings.en = Some("Push Notification".to_string());

let mut notification = Notification::new("YOUR_APP_ID".to_string());
Expand All @@ -65,21 +66,21 @@ let mut notification = Notification::new("YOUR_APP_ID".to_string());
notification.email_subject = Some("Important Update".to_string());
notification.email_body = Some("<h1>Hello!</h1><p>This is an HTML email.</p>".to_string());
notification.included_segments = Some(vec!["Subscribed Users".to_string()]);
notification.channel_for_external_user_ids = Some("email".to_string());
notification.target_channel = Some(TargetChannelType::Email);

let response = default_api::create_notification(&config, notification).await;
```

## Send an SMS

```rust
let mut contents = StringMap::new();
let mut contents = LanguageStringMap::new();
contents.en = Some("Your SMS message content here".to_string());

let mut notification = Notification::new("YOUR_APP_ID".to_string());
notification.contents = Some(Box::new(contents));
notification.included_segments = Some(vec!["Subscribed Users".to_string()]);
notification.channel_for_external_user_ids = Some("sms".to_string());
notification.target_channel = Some(TargetChannelType::Sms);
notification.sms_from = Some("+15551234567".to_string());

let response = default_api::create_notification(&config, notification).await;
Expand Down
Loading