Comments (4)
It would probably help if you'd post your code.
from a2.
Here is the code:
use a2::{Client, Endpoint, NotificationBuilder, NotificationOptions, PlainNotificationBuilder};
use argparse::{ArgumentParser, Store, StoreOption, StoreTrue};
use pretty_env_logger;
use std::fs::File;
use tokio;
// An example client connectiong to APNs with a certificate and key
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
pretty_env_logger::init();
let mut certificate_file = String::from("/Users/rajesh/Downloads/BlueshiftPushBluePkcs.p12");
let mut password = String::from("blueshift");
let mut device_token = String::from("860177d09c9a45900a20b1bf5de4eeddd4046b151bb837523d3218fdb135ead2");
let mut message = String::from("Ch-check it out!");
let mut sandbox = true;
let mut topic: Option<String> = Some(String::from("com.blueshift.reads"));
// Read the private key and certificate from the disk
let mut certificate = File::open(certificate_file).unwrap();
// Which service to call, test or production?
let endpoint = if sandbox {
Endpoint::Sandbox
} else {
Endpoint::Production
};
// Connecting to APNs using a client certificate
let client = Client::certificate(&mut certificate, &password, endpoint).unwrap();
let options = NotificationOptions {
apns_topic: topic.as_ref().map(|s| &**s),
..Default::default()
};
// Notification payload
let mut builder = PlainNotificationBuilder::new(message.as_ref());
builder.set_sound("default");
builder.set_badge(1u32);
let payload = builder.build(device_token.as_ref(), options);
println!("Sending payload");
let response = client.send(payload).await?;
println!("Sent: {:?}", response);
Ok(())
}
from a2.
Using the example code on macOS to send a notification with token based authentication, I am getting the exact same error. I am trying with a2 v0.6.0 and have added tokio v1.5.0 as dependency. I am new to Rust as well.
The backtrace ends with the following:
39: tokio::runtime::Runtime::block_on
at /Users/franklin/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.5.0/src/runtime/mod.rs:452:43
40: notifier::main
at /Users/franklin/Developer/rust/Notifier/src/main.rs:9:1
41: core::ops::function::FnOnce::call_once
at /Users/franklin/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
If I use a2 v0.5.3 and add tokio v0.2.25 as dependency, everything works fine.
from a2.
Apparently, this is solved by enabling the runtime
feature of the hyper dependency.
from a2.
Related Issues (20)
- http2 error: protocol error: not a result of an error HOT 2
- Compilation broken with latest nightlies HOT 1
- Default apns_priority doesn't match expectation HOT 4
- changed lifetimes HOT 8
- 'tokio-runtime-worker' has overflowed its stack fatal runtime error: stack overflow
- Upgrade to tokio 0.3 HOT 3
- Upgrade to tokio 1.0 HOT 1
- API compatibility breakage in new minor version v0.6.2 HOT 2
- Panic: 'executor must be set' from hyper-0.14.15 when running examples.
- feat: `.editorconfig`
- fix: add `tracing` feature back
- feat: Switch `&str` params HOT 4
- Client panicked inside hyper-alpn library
- Sending a payload with invalid uri chars panics
- async-std support? HOT 1
- How to set timeout on send?
- Panic `executor must be set` occurs when hyper dep with "tcp" feat enabled is not in dependencies HOT 1
- Automate publish ops
- Request to send keep-alives on idle connections HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from a2.