• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
PhoneGap 通信原理和插件系统
 

PhoneGap 通信原理和插件系统

on

  • 1,052 views

 

Statistics

Views

Total Views
1,052
Views on SlideShare
1,052
Embed Views
0

Actions

Likes
1
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    PhoneGap 通信原理和插件系统 PhoneGap 通信原理和插件系统 Presentation Transcript

    • PhoneGap通信原理和插件系统@范圣刚
    • Agenda•通信机制的实现原理•获取 PhoneGap 插件•使⽤用 PhoneGap 插件•开发 PhoneGap 插件
    • Corvoda.exec() in cordova.js
    • Android 平台通信原理
    • nativeapiprovider
    • promptbasednativeapi(json转
    • 浏览器的 prompt
    • DroidGap.java
    • CordovaActivity
    • CordovaChromeClient.java
    • iOS 平台的通信原理封装的命令对象 + 不可⻅见的⼀一个 iFrame
    • github.com/phonegap/phonegap-plugins
    • 使⽤用 SMSPlugin 发送短信https://github.com/dimitrismistriotis/SendSmsCordovaPlugin
    • 插件编写
    • •⾄至少有⼀一个扩展⾃自 CordovaPlugin 类的 Java 类•必须要覆盖⼀一个 CordovaPlugin 的 execute ⽅方法
    • JS 和本机代码通讯的⽅方法cordova.exec( function(winParam) {},function(error) {},"service","action",["firstArgument", "secondArgument", 42, false]);•function(winParam){} - exec 执⾏行成功的回调⽅方法•function(error){} - 操作未成功的回调⽅方法•service - 本地服务名称。⼀一般映射到⼀一个类。•action - 执⾏行的服务的具体操作。本机端收到 exec调⽤用时收到的参数,⼀一般映射到⼀一个本机的⽅方法•[arguments] - 传⼊入本机环境的参数
    • notification.alert in cordova.js
    • Notification.java in cordova-android
    • alert() method
    • Camera.getPicture() incordova.js(iOS)
    • CDVCamera.h
    • CDVinvokeUrlCommand.h