< div> 3. Install ioinc
Hybrid APP Development Summary
npm--registry https://registry.npm.taobao.org info underscore
div>
< div> Here I use WebStorm to edit the code
< div> 3. Install ioinc
npm--registry https://registry.npm.taobao.org info underscore
< div> Here I use WebStorm to edit the code
cordova plugin add plugin url
div>
cordova platform update [email protected]
< div>
I recently made a Hybrid APP. Now I will add relevant knowledge The technical summary is as follows
1. Technology used
html5, angularJs, cordova, ionic
Second, environment setup
Require To use cordova and ionic development to build a good cordova and ionic development environment
The steps are as follows:
1. Install node.js
Download link https://nodejs. org/en/
2. Install cordova
Under windows, enter npm install under cmd and -g cordova
< span style="font-size:16px"> Under mac, enter sudo npm install -g cordova
< /p>
3. Install ioinc
wind Enter npm install under cmd under ows ionic
Enter sudo npm install -g ionic in the terminal under mac< /p>
Sometimes it will be slow to install with npm , You can use Taobao mirror
npm--registry https://registry.npm.taobao.org info underscore< /code>
npm--registry https://registry.npm.taobao.orginfo underscore
< /span>
Related question linkhttps://cnodejs.org/topic/ 4f9904f9407edba21468f31e
3. Project creation, installation and operation
After the environment is set up, we will create the project p>
1. Create a project p>
Use the command ioinc start yyt
After the command is completed, A yyt folder will be generated under the current path
2. Configure the platform
cd yyt to enter the project folder
Use the command ionic platform add android
If you want to configure ios, it’s ionic platform add ios
3.build
Use the command ionic build android
ionic build ios if it’s ios
span>
4. Run To mobile phone
Android mobile phone
After connecting your phone, use ionic run android
iPhone
After build, enter platfroms-->ios
Find xxx.xcodeproj in this path and open it with Xcode
Use Xcode point to run, you can run on your phone
4. Development tools p>
Here I use WebStorm to edit the code
http://bbs.phonegap100.com/thread-1567-1-1.html
5. Code structure
The code is written using the angularJs framework
The page display is based on index.html as the main page. The content of different pages is displayed in ion-nav-view, and the html of each page is placed under www/templates
Each html page has a corresponding controller.js, these js files are placed under www/js/controller< /p>
Defined in the app.js file Related modules and configuration state machine
config.js configures related global variables
The http request uses the $http service of angularJs, and the relevant code is under service.js
style.css is a custom style file, generally used to rewrite related ionic styles, Achieve custom style effects
VI. Development-related issues
1. Icon and startup page
ionic can use commands to automatically generate icons and startup pages, the method is as follows
(1) Under the resouces file under the project, put the picture icon.png and picture splash.png,< /p>
icon.png image requirements are 192*192px, splash.png requirements are 2208*2208px,
(2) Then switch to the project directory under cmd and enter the command
span>
ionic resources
After finishing, it will automatically Generate an Images of different sizes on the droid platform and ios platform will be automatically configured under the config.xml file
>
Related reference links
http://ionichina.com/ topic/54e455ab2be672f1111c01e2
The problem I encountered: After the image is generated, an error will be reported after executing ionic build android:
p>
Execution failed for task':mergeDebugResources'
libpng error : Read Error
Reason: There is a problem with some of the automatically generated pictures; Solution: Find the problematic picture, replace it with a normal picture, and build it again
2. Plug-in
When you need to call native functions, you need to use plug-ins, here you can use third-party plug-ins, or write your own plug-ins
(1) You can use ngCordova’s plug-ins when using third-party plug-ins. To use ngCordova, please refer to the following steps< /span>
①Install Git
Download ngCordova download link http://angular-js.in/ng-cordova/
③ Import the ng-cordova.js file
span>
Bring ng-cordova.js or ng-cordova.min.js into index.html and put it before cordova.js, AngularJS Ionic After the document (because ngCordova relies on AngularJS).
④ Introduce the dependency of ng-cordova
Introduce the dependency of ng-cordova in app.js, angular.module('myApp',['ngCordova']);
⑤Install plug-in documentation link http://ngcordova.com/docs/plugins/
The method of installing the plug-in is very simple. Switch to the project path under cmd and use the command
cordova plugin add plugin url
command to delete plugin cordova plugin rm plugin id
To view the plug-in list of the current project cordova plugin list
The problem I have encountered:
< span style="font-size:16px">
< span style="font-size:16px"> Reason: The cordova-android version is too low, you can upgrade; use the command
code style="margin:0px; padding:0px; border:0px; background-color:rgb(238,238,238)">cordova platform update [email protected] s pan>
(2) Write your own plug-in
After cordova3.X, you need to write the plug-in outside the project and insert it into the project by command
Steps to write the plug-in As follows:
(1) Create a folder under a certain path, such as EchoPlugin
(2) Create src, www folder, plugin.xml file in EchoPlugin directory
src is for native code files, www is for js files, and plugin.xml is related configuration information
( 3) Write the java file, js file, plugin.xml file
(4) Use the command cordova plugin add under the project path Path to install the plug-in into the project
Related reference links
http://www.wenzhixin.net.cn/2014/03/20/cordova_my_pl ugin
3. Map
I Here is the Baidu Map JavaScript API
For details, please refer to the official document
http://developer.baidu.com/map/index.php?title=jspopular
html5 positioning function, I found that html5 can’t be implemented on Android phones. Later I used one
地图的插件实现了定位功能,插件链接如下:
http://www.phonegap100.com /plugininfo_40.html
注意:该插件返回的数据是字符串,不是js对象,需要自己拆分字符串,将经度、纬度提取出来
我遇到的问题: 百度地图在ion-content中不显示,需要将ion-content中的scroll参数设置为false即可显示了
4.app更新
app更新需要装获取本地版本插件、file插件、file-trasnser插件和file-opener插件
相关链接http://bbs.phonegap100.com/thread-2046-1-1.html
实现思路,在程序启动时先获取服务器上的程序的版本号,与本地版本号比较,如果不一致,则下载apk到本地,然后打开
5.推送
我这里是集成个推的SDK,需要在个推注册账号,登记应用,然后按照官方文档集成,集成
成功后,会获取到一个clientid。相关链接http://docs.getui.com/pages/viewpage.action?pageId=589866
推送消息的类型由服务端决定,比如是打开网页,或者打开应用、或者是透传消息,详情请见官方文档
实现打开指定页面的思路:服务端推送透传消息,以JSON格式的字符串推送过来,然后app端解析JSON数据,获取相关
的参数,然后app端自定义一个Notification,点击Notification跳转到指定的页面
七、其它相关链接
cordova官网http://cordova.apache.org/
ionic官网http://ionicframework.com/
WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3806 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC