Skip to content

tiffanyli/motion-wechat

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WechatSDK for RubyMotion

Code Climate

  • RubyMotion wrapper for WechatSDK
  • Improving ...
  • Update** not use pod, use vendor

Setup

Add MotionWechat to your Gemfile, and run bundle install:

gem 'motion-wechat'

Edit the Rakefile of your RubyMotion project and add the following require line:

# After the line that require Rubymotion
require 'bundler'
Bundler.require

Then setup configuration in your Rakefile:

MotionWechat::Config.setup(app, 'app_key', 'app_secret')

Then register app in your app_delegate.rb

MotionWechat::API.instance.registerApp

Usage

Basic:

MotionWechat::API.instance.send_webpage "http://www.rubymotion.com", \
  title: "Ruby Motion", description: "Awesome way to write ios/osx app"

Wechat Authorization:

1. authorize, this will direct user to wechat app

MotionWechat::API.instance.authorize

2. then make sure you have weixin delegate set up in app_delegate.rb

def application(application, handleOpenURL:url)
  WXApi.handleOpenURL(url, delegate:self)
end

def application(application, openURL:url, sourceApplication:sourceApplication, annotation:annotation)
  WXApi.handleOpenURL(url, delegate:self)
end

3. set up onResp in app_delegate.rb. this is when it comes back from wexin app

def onResp(resp)
  if resp.is_a? SendAuthResp
    # token lang country code
    MotionWechat::API.instance.registerClient resp.code
    MotionWechat::API.instance.get_user_info do |info|
      p info
    end
  end
end

TODO

  • delegate helpers, i.e. WXApi.handleOpenURL(url, delegate:self)
  • state & key validating in application(application, handleOpenURL:url)

Contributions

smartweb

Fork, please!

About

Rubymotion gem to easily use WeChatSDK

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%