0.0
No commit activity in last 3 years
No release in over 3 years
Rubymotion gem to easily use WeChatSDK
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 2.3.1
~> 1.7.0
 Project Readme

WechatSDK for RubyMotion

Code Climate

This is a RubyMotion gem for WechatSDK to integrate WeChat API with your RubyMotion app. See http://dev.wechat.com/wechatapi/documentation

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
    # resp has *token* *lang* *country* *code*
    MotionWechat::API.instance.registerClient resp.code
    MotionWechat::API.instance.get_user_info do |info|
      # send *info* to server for authentication
    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!