icyleaf / xiaomi-push Goto Github PK
View Code? Open in Web Editor NEW(unofficial) xiaomi push server sdk for ruby - 非官方小米推送服务端 Ruby SDK
Home Page: http://www.rubydoc.info/gems/xiaomi-push/frames
(unofficial) xiaomi push server sdk for ruby - 非官方小米推送服务端 Ruby SDK
Home Page: http://www.rubydoc.info/gems/xiaomi-push/frames
我下载了这个包到本地,然后在push.rb 里面按照示例写了一个demo,但是缺少必要的
Must input one of: regid/topic/alias
push.rb
require 'xiaomi/push/version'
require 'xiaomi/push/error'
require 'xiaomi/push/const'
require 'xiaomi/push/client'
require 'xiaomi/push/devices/ios'
require 'xiaomi/push/devices/android'
require 'xiaomi/push/services/message'
require 'xiaomi/push/services/topic'
require 'xiaomi/push/services/feedback'
puts client_android = Xiaomi::Push::Android.new('ddddddd')
client_android.use_production!
message_android = Xiaomi::Push::Message::Android.new(
title:'标题要有吸引力',
description:'描述可以在手机显示两行',
notify_type:'DEFAULT_ALL',
extras: {
source: 'mpush'
}
)
puts client_android.message.send({alias:'xxxxx', message: message_android})
xiaomi返回的错误信息:
#<Xiaomi::Push::Android:0x007fa3526c6e78>
{"result"=>"error", "reason"=>"Must input one of: regid/topic/alias", "trace_id"=>"Xlm57b34466136027247wT", "code"=>21305, "description"=>"缺少必要的参数"}
和rails 的gemfile 一起安装,之后运行rails s会报错如下:
/Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- dotenv (LoadError)
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/xiaomi-push-0.2.3/lib/xiaomi/push.rb:14:in `<top (required)>'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/bundler-1.8.3/lib/bundler/runtime.rb:85:in `require'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/bundler-1.8.3/lib/bundler/runtime.rb:85:in `rescue in block in require'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/bundler-1.8.3/lib/bundler/runtime.rb:68:in `block in require'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/bundler-1.8.3/lib/bundler/runtime.rb:61:in `each'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/bundler-1.8.3/lib/bundler/runtime.rb:61:in `require'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/bundler-1.8.3/lib/bundler.rb:134:in `require'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/zeus-0.15.4/lib/zeus/rails.rb:97:in `default_bundle'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/zeus-0.15.4/lib/zeus.rb:200:in `run_action'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/zeus-0.15.4/lib/zeus.rb:74:in `block (2 levels) in boot_steps'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/zeus-0.15.4/lib/zeus/load_tracking.rb:7:in `features_loaded_by'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/zeus-0.15.4/lib/zeus.rb:73:in `block in boot_steps'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/zeus-0.15.4/lib/zeus.rb:56:in `catch'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/zeus-0.15.4/lib/zeus.rb:56:in `boot_steps'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/zeus-0.15.4/lib/zeus.rb:48:in `go'
需要手动加入 'dotenv' 到gemfile里
文档地址: https://dev.mi.com/console/doc/detail?pId=1163
现有官方支持 SDK: https://dev.mi.com/mipush/downpage/
If I run with following command:
xmp message --device android --secret '********' -i 'biao' -d 'adasd'
will throw error:
/Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/commander-4.3.5/lib/commander/runner.rb:391:in `block in require_program': program version required (Commander::Runner::CommandError)
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/commander-4.3.5/lib/commander/runner.rb:390:in `each'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/commander-4.3.5/lib/commander/runner.rb:390:in `require_program'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/commander-4.3.5/lib/commander/runner.rb:52:in `run!'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/commander-4.3.5/lib/commander/delegates.rb:15:in `run!'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/commander-4.3.5/lib/commander/import.rb:5:in `block in <top (required)>'
/Users/tangmonk/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:121:in `require': cannot load such file -- dotenv (LoadError)
from /Users/tangmonk/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:121:in `require'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/xiaomi-push-0.2.1/lib/xiaomi/push.rb:15:in `<top (required)>'
from /Users/tangmonk/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:69:in `require'
from /Users/tangmonk/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:69:in `require'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/gems/xiaomi-push-0.2.1/bin/xmp:6:in `<top (required)>'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/bin/xmp:23:in `load'
from /Users/tangmonk/.rvm/gems/ruby-2.1.5/bin/xmp:23:in `<main>'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.