PhoneGap 微信插件 for iOS
Weixin
微信插件
Adding the Plugin to your project
1.add weixin.js to your www folder and include it to your html file below cordova.js
- <script type="text/javascript" charset="utf-8" src="cordova.js">
- <script type="text/javascript" charset="utf-8" src="weixin.js">
复制代码
2.Add WeChatSDK & SinaWeixinPlugin src files to your project.
3.Add Weixin-SinaWeixinPlugin [key-value] to Cordova.plist->Plugins
4.Modify project info.plist : add URL types -> URl Schemes -> Item0-'your appId' (key-value)
Usage
sina.weixin.registerApp(onSuccess,onError,appId)
在微信终端程序中注册第三方应用说明:需要在每次启动第三方应用程序时调用。第一次调用后,会在微信的可用应用列表中出现。
- appId 微信开发的ID (通过http://open.weixin.qq.com/ 申请)
- onSuccess 注册成功时的回调函数
- onError 注册失败时的回调函数
errCode 错误值
errStr 错误说明
demo
- sina.weixin.registerApp(function(){
- registed=true;
- },onError,"XXXXXXXXX");// 填入申请的微信应用开发appId
- function onError(response){
- var detail = document.getElementById("detail");
- detail.innerHTML="error:"+response.errCode;
- detail.innerHTML=detail.innerHTML+"
- "+response.errStr;
- }
复制代码
sina.weixin.getWXAppInstallUrl(onSuccess,onError)
获取微信的itunes安装地址
- onSuccess 获取成功时回调函数
- onError 获取失败时回调函数
errCode 错误值
errStr 错误说明
function onSuccess(url){ } url 为微信的itunes安装地址
function onError(error){ }
demo
- sina.weixin.getWXAppInstallUrl(function(resultUrl){
- console.log(resultUrl);
- },function(error){
- console.log(error.errCode);
- console.log(error.errStr);
- });
复制代码
sina.weixin.isWeixinInstalled(onSuccess,onError)
检查微信是否已被用户安装
- onSuccess 微信已安装的回调函数
- onError 微信未安装的回调函数
errCode 错误值
errStr 错误说明
demo
- sina.weixin.isWeixinInstalled(function(){
- console.log('is installed');
- },function(){
- console.log('not installed');
- });
- sina.weixin.isSupportApi(onSuccess,onError)
复制代码
判断当前微信的版本是否支持OpenApi
- onSuccess 当前微信版本支持OpenApi时的回调函数
- onError 当前微信版本不支持OpenApi时的回调函数
errCode 错误值
errStr 错误说明
demo
- sina.weixin.isSupportApi(function(){
- console.log('is support api');
- },function(){
- console.log('not support api');
- });
复制代码
sina.weixin.openWXApp(onSuccess,onError)
打开微信
- onSuccess 成功时的回调函数
- onError 失败时的回调函数
errCode 错误值
errStr 错误说明
demo
- sina.weixin.openWXApp(function(){
- console.log('open success');
- },function(){
- console.log('open error');
- });
复制代码
sina.weixin.textContent(onSuccess, onError, types, text)
发送/获取 文本信息
发送:发送请求到微信,等待微信返回应答
获取:收到微信的请求,发送文本类型应答给微信,并切换到微信界面
- onSuccess 成功时的回调函数
- onError 失败时的回调函数
- types 设置对文本信息的处理类型
send 表示:发送文本信息请求到微信
get 表示:收到微信的请求,发送文本类型应答给微信
- text 文本信息内容
demo
- function getTextContent() {
- sina.weixin.textContent(onSuccess,onError,"get","Sina App Engine");
- }
- function sendTextContent() {
- sina.weixin.textContent(onSuccess,onError,"send","hello world");
- }
- function onSuccess(){
- console.log('success');
- }
- function onError(response){
- var detail = document.getElementById("detail");
- detail.innerHTML="error:"+response.errCode;
- detail.innerHTML=detail.innerHTML+"
- "+response.errStr;
- }
复制代码
sina.weixin.imageContent(onSuccess, onError, types, imageUrl, options)
发送/获取 图片信息
发送:发送图片信息请求到微信,等待微信返回应答
获取:收到微信的请求,发送图片类型应答给微信,并切换到微信界面
- onSuccess 成功时的回调函数
- onError 失败时的回调函数
- types 设置对图片信息的处理类型
send 表示:发送图片信息请求到微信
get 表示:收到微信的请求,发送图片类型应答给微信
- imageUrl 图片的Url链接
- options 相关参数项,字典类型。包括
title
description
demo
- function sendImageContent(){
- //从相册选择图片,并发送到微信应用
- var app={
- onCameraSuccess:function(imageURI){
- sina.weixin.imageContent(onSuccess,onError,"send",imageURI,{
- title:"kris",
- description:"picture",
- });
- },
- onCameraFail:function(msg){
- console.log('error msg:'+msg);
- },
- getPicture:function(){
- navigator.camera.getPicture(app.onCameraSuccess, app.onCameraFail, {
- quality: 50,
- destinationType: Camera.DestinationType.FILE_URI,
- sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
- saveToPhotoAlbum: false
- });
- }
- };
- app.getPicture();
- }
- function getImageContent(){
- //收到来自微信的请求后,发送图片应答给微信
- sina.weixin.getImageContent(onSuccess,onError,"http://pluginlist.sinaapp.com/client/images/music.png",{
- title:"kris",
- description:"picture",
- });
- }
- function onSuccess(){
- console.log('success');
- }
- function onError(response){
- var detail = document.getElementById("detail");
- detail.innerHTML="error:"+response.errCode;
- detail.innerHTML=detail.innerHTML+"
- "+response.errStr;
- }
复制代码
sina.weixin.musicContent(onSuccess, onError, types, musicUrl, options)
发送/获取 音乐信息。musicUrl和lowBandUrl不能同时为空。
发送:发送音乐信息请求到微信,等待微信返回应答
获取:收到微信的请求,发送音乐类型应答给微信,并切换到微信界面
- onSuccess 成功时的回调函数
- onError 失败时的回调函数
- types 设置对音乐信息的处理类型
send 表示:发送音乐信息请求到微信
get 表示:收到微信的请求,发送音乐类型应答给微信
- musicUrl 音乐数据的url地址,不支持本地音乐URL。musicUrl和lowBandUrl不能同时为空。
- options 相关参数项,字典类型。包括
title 音乐信息标题
description 音乐信息描述内容
lowBandUrl 音乐lowband数据的url地址,不支持本地音乐URL。musicUrl和lowBandUrl不能同时为空。
thumbUrl 音乐信息缩略图url。当thumbUrl和thumbData同时设置时,采用thumbData。
thumbData 音乐信息缩略图base64数据,大小不能超过32K。当thumbUrl和thumbData同时设置时,采用thumbData。
demo
- function sendMusicContent(){
- sina.weixin.musicContent(onSuccess,onError,"send",
- "http://pluginlist.sinaapp.com/client/music/Sunshine.mp3",
- {
- title:"Sunshine",
- description:"Happy Music",
- thumbUrl:"http://pluginlist.sinaapp.com/client/images/music.png"
- });
- }
- function getMusicContent(){
- sina.weixin.musicContent(onSuccess,onError,"get",
- "http://pluginlist.sinaapp.com/client/music/Sunshine.mp3",
- {
- title:"Sunshine",
- description:"Happy Music",
- thumbUrl:"http://pluginlist.sinaapp.com/client/images/music.png"
- });
- }
- function onSuccess(){
- console.log('success');
- }
- function onError(response){
- var detail = document.getElementById("detail");
- detail.innerHTML="error:"+response.errCode;
- detail.innerHTML=detail.innerHTML+"
- "+response.errStr;
- }
复制代码
sina.weixin.videoContent(onSuccess, onError, types, videoUrl, options)
发送/获取 视频信息。videoUrl和lowBandUrl不能同时为空。
发送:发送视频信息请求到微信,等待微信返回应答
获取:收到微信的请求,发送视频类型应答给微信,并切换到微信界面
- onSuccess 成功时的回调函数
- onError 失败时的回调函数
- types 设置对视频信息的处理类型
send 表示:发送视频信息请求到微信
get 表示:收到微信的请求,发送视频类型应答给微信
- videoUrl 视频数据的url地址,不支持本地视频URL。videoUrl和lowBandUrl不能同时为空。
- options 相关参数项,字典类型。包括
title 视频信息标题
description 视频信息描述内容
lowBandUrl 视频lowband数据的url地址,不支持本地视频URL。videoUrl和lowBandUrl不能同时为空。
thumbUrl 视频信息缩略图url。当thumbUrl和thumbData同时设置时,采用thumbData。
thumbData 视频信息缩略图base64数据,大小不能超过32K。当thumbUrl和thumbData同时设置时,采用thumbData。
demo
- function getVideoContent(){
- sina.weixin.videoContent(onSuccess,onError,"get",
- "http://www.tudou.com/listplay/0nYp1obVv60/mA_xdJq7lSo.html",
- {
- title:"video",
- description:"Get Happy Video",
- thumbUrl:"http://pluginlist.sinaapp.com/client/images/video.png"
- });
- }
- function sendVideoContent(){
- sina.weixin.videoContent(onSuccess,onError,"send",
- "http://www.tudou.com/listplay/0nYp1obVv60/mA_xdJq7lSo.html",
- {
- title:"video",
- description:"Happy Video",
- thumbUrl:"http://pluginlist.sinaapp.com/client/images/video.png"
- });
- }
复制代码
sina.weixin.webpageContent(onSuccess, onError, types, webpageUrl, options)
发送/获取 网页信息
发送:发送网页信息请求到微信,等待微信返回应答
获取:收到微信的请求,发送网页类型应答给微信,并切换到微信界面
- onSuccess 成功时的回调函数
- onError 失败时的回调函数
- types 设置对网页信息的处理类型
send 表示:发送网页信息请求到微信
get 表示:收到微信的请求,发送网页类型应答给微信
- webpageUrl 网页url地址
- options 相关参数项,字典类型。包括
title 网页信息标题
description 网页信息描述内容
thumbUrl 网页信息缩略图url。当thumbUrl和thumbData同时设置时,采用thumbData。
thumbData 网页信息缩略图base64数据,大小不能超过32K。当thumbUrl和thumbData同时设置时,采用thumbData。
demo
- function sendWebpageContent(){
- sina.weixin.webpageContent(onSuccess,onError,"send",
- "http://sae.sina.com.cn/?m=devcenter&catId=235",
- {
- title:"新浪移动云平台介绍",
- description:"新浪移动云是在SAE基础上的子平台,专注于为移动设备同时提供云+端的能力。\n为方便开发者使用,移动云直接集成在SAE在线管理平台中。",
- thumbUrl:"http://pluginlist.sinaapp.com/client/images/icon.png"
- });
- }
- function getWebpageContent(){
- sina.weixin.webpageContent(onSuccess,onError,"get",
- "http://sae.sina.com.cn/?m=devcenter&catId=235",
- {
- title:"新浪移动云平台介绍",
- description:"新浪移动云是在SAE基础上的子平台,专注于为移动设备同时提供云+端的能力。\n为方便开发者使用,移动云直接集成在SAE在线管理平台中。",
- thumbUrl:"http://pluginlist.sinaapp.com/client/images/icon.png"
- });
- }
复制代码
sina.weixin.APPContent(onSuccess, onError, types, options)
发送/获取 APP扩展信息。微信需要处理这种APP扩展信息时,会调用该第三方应用的监听回调方法来处理。监听回调方法的设置及相应操作,请参考sina.weixin.setResponser(responseString)。
发送:发送APP扩展信息请求到微信,等待微信返回应答
获取:收到微信的请求,发送APP扩展类型应答给微信,并切换到微信界面
- onSuccess 成功时的回调函数
- onError 失败时的回调函数
- types 设置对APP扩展信息的处理类型
send 表示:发送APP扩展信息请求到微信
get 表示:收到微信的请求,发送APP扩展类型应答给微信
- options 相关参数项,字典类型。包括
title APP扩展信息标题
description APP扩展信息描述内容
thumbUrl APP扩展信息缩略图url。当thumbUrl和thumbData同时设置时,采用thumbData。
thumbData APP扩展信息缩略图base64数据,大小不能超过32K。当thumbUrl和thumbData同时设置时,采用thumbData。
extInfo 自定义简单数据,长度不能超过2K。微信应用会回传给第三方应用处理。extInfo与fileData不能同时为空。
fileData APP文件数据,JSON对象,大小不能超过10M。该数据发送给微信好友,微信好友需要点击后下载数据,微信应用会回传给第三方应用处理。extInfo与fileData不能同时为空。
url 若第三方应用不存在,微信应用会打开该url所指的App下载地址。
demo
- function getAPPContent(){
- sina.weixin.APPContent(onSuccess,onError,"get",
- {
- title:"App消息",
- description:"您的App消息到啦,快去看看吧",
- thumbUrl:"http://pluginlist.sinaapp.com/client/images/icon.png",
- extInfo:"dictionary",
- url:"http://sae.sina.com.cn",
- fileData:JSON.stringify(
- {title:"App消息名称",
- description:"内容描述",
- thumbUrl:"缩略图链接地址"}
- )
- });
- }
- function sendAPPContent(){
- sina.weixin.APPContent(onSuccess,onError,"send",
- {
- title:"App消息",
- description:"您的App消息到啦,快去看看吧",
- thumbUrl:"http://pluginlist.sinaapp.com/client/images/icon.png",
- extInfo:"send APP",
- url:"http://www.sina.com.cn",
- fileData:JSON.stringify(
- {title:"App消息名称",
- description:"内容描述",
- thumbUrl:"缩略图链接地址"}
- )
- });
- }
复制代码
sina.weixin.setResponser(responseString)
设置监听回调函数,接收来自微信应用的请求
- responseString 监听回调方法的名字,默认为receiveResponse
function receiveResponse(response);
- type 回调信息的类型
0 表示显示APP扩展格式信息。
4 表示来自微信的请求信息,获取内容后返回给微信应用。
- 当type==0时,response还包括下面几项:
extInfo 第三方应用自定义简单数据,微信应用会回传给第三方应用处理。[说明:长度不能超过2K]
fileData APP文件数据,JSON对象。该数据发送给微信好友,微信好友需要点击后下载数据,微信应用会回传给第三方应用处理。[说明:大小不能超过10M]
thumbData APP扩展格式信息缩略图base64数据。
demo
- sina.weixin.setResponser("receiveResponse");
- function receiveResponse(response){
- if(response.type==0)
- {//显示来自第三方的APP扩展信息
- var detail = document.getElementById("detail");
- detail.innerHTML="extInfo:"+response.extInfo;
- var a=JSON.parse(response.fileData);
- detail.innerHTML=detail.innerHTML+"
- title:"+a.title;
- detail.innerHTML=detail.innerHTML+"
- description:"+a.description;
- detail.innerHTML=detail.innerHTML+"
- thumbUrl:"+a.thumbUrl;
- var viewport = document.getElementById('viewport');
- viewport.style.display = "";
- document.getElementById("picture").src = "data:image/jpeg;base64," + response.thumbData;
- }
- else if(response.type==4)
- {// 来自微信的请求信息,跳转到获取信息页面
- var btn1=document.getElementById("btn1");
- btn1.οnclick=function(){sina.weixin.textContent(onSuccess,onError,"get","Sina App Engine");};
- btn1.innerHTML="获取文本";
- }
- }
复制代码
PhoneGap 微信插件 for iOS相关推荐
- Flutter实现微信支付和iOS IAP支付
Flutter支付 微信支付 iOS IAP应用内支付 测试IAP中断购买的测试 公司近期将收费的功能排期了,由于项目做的是线上教育,提供的服务属于虚拟物品.根据iOS官方的规定,虚拟物品交易只能使用 ...
- android微信支付插件,AppCan文档中心-Android微信插件接入指引
开发者在使用APPCAN平台提供的微信插件时,需要配置相关的包名,AppID和签名.具体步骤如下(以大众版打包为例): 1. 获取apk相关的包名和签名 1.1包名 自定义包名(推荐使用) APPCA ...
- idea可以使用flash框架吗_这个框架厉害了,使用它几分钟就可以编写一个微信插件...
大家好,我是章鱼猫. 今天给大家推荐的这个项目是「Wechat Spellbook」-- 一个使用 Kotlin 编写的开源微信插件框架,底层需要 Xposed 或 VirtualXposed 等 H ...
- 对hash签名失败_vue项目中微信jssdk在ios签名失败
一.问题描述 1. vue项目中微信jssdk签名时,在安卓和ios是有差异的,签名时使用的url=window.location.href.split('#')[0],此时在安卓没问题,在ios会导 ...
- ios 上传图片失败 小程序_微信小程序ios端 使用ajaxSubmit上传图片失败,android没问题...
微信小程序ios端 使用ajaxSubmit上传图片失败,android没问题 微信小程序开发上传图片,使用ajaxsubmit,post请求,form设置multipart/form-data, a ...
- P3-weixin-2.0.1 版本发布,JAVA微信插件框架
P3-weixin-2.0.1版本发布(JAVA微信插件框架) P3-Weixin是轻量级Java插件开发框架,采用主流JAVA技术,集成强大代码生成器,增删改查一键生成,封装统一后台管理系统,不仅适 ...
- P3-weixin-2.0.0版本发布(微信插件式开发框架)
P3-weixin-2.0.0版本发布(微信插件式开发框架) 1.P3-weixin为何诞生 现在微信越来越火,基于微信的公众号和服务号越来越丰富,单一的微信管家系统已经满足不了微信的需求.Jeecg ...
- 解决微信小程序IOS中使用picker弹出内容和手机软键盘重叠的问题
解决微信小程序IOS中使用picker弹出内容和手机软键盘重叠的问题 项目需求: 一个信息提交页面:有input输入框,有picker选择器 遇到的问题: 点击input输入框时,手机自动弹出键盘,但 ...
- iOS小技能: 开发 uni 原生插件(支持iOS Extension)
文章目录 引言 I 开发 uni-app 原生插件 1.1 SDK 包结构说明 1.2 目录格式配置 II iOS Extension(扩展) 2.1 插件作者配置 2.2 插件使用者配置 III 注 ...
最新文章
- 深度学习入门Fast.ai 2.0上线!自带中文字幕,所有笔记、资源全部免费!
- 第四次作业 孙保平034 李路平029
- px word 表格宽度_「Word技巧」掌握这六个Word表格处理技巧,表格排版不再是问题...
- [转]Win XP常遇网络故障分析:局域网问题
- python 螺旋数组_奇技淫巧 - Python绘制各种简单优美曲线
- 类加载器的理解——基于Launcher类
- IDEA安装插件及安装失败的处理方法
- c语言输出字符太阳,〖作业〗 C语言程序设计
- python图片马赛克_利用Python对图片进行马赛克处理
- Qt C++招聘要求
- 博途IEC TIME数据类型_基于博途V15 西门子S7-1200数据处理指令应用-移动操作
- GY-BMP280-3.3 高精度大气压强传感器模块
- 利用java对接阿里云sls服务(aliyun-log)做浏览记录
- 英雄联盟 python 刷等级_厉害了,30行python代码爬取英雄联盟全英雄皮肤
- 记我的启蒙老师谢朝晖老师
- java计算机毕业设计学校意见征集系统源码+系统+mysql数据库+lw文档
- 《金蝶ERP-K/3完全使用详解》——6.2 产品预测单
- 哈希(Hash)算法
- 文章结构层次序数(序号)的规范要求
- 【编程实践】Python编程手册 《Python极简教程》
热门文章
- hotnets2018 Networking in Heaven as on Earth 阅读报告
- centos mysql 1146_MySQL查询报错:ERROR 1146 (42S02): Table 'craw.sitePageConfig' doesn't exist
- 机器学习——特征工程——数据的标准化(Z-Score,Maxmin,MaxAbs,RobustScaler,Normalizer)
- 用瑞利准则研究显微镜物镜的分辨率
- 读《魔鬼搭讪学》有感
- Objective-C类别(catagory)
- 基于python的 ping 网络状态监测方法 亲测有效
- 思科网院 Routing and Switching Essentials ( 版本 6.00) - RSE 6.0 第 1 章考试答案
- Android 开发技术周报
- Iron WebScraper 网络爬虫