Ionic framework 用于angularjs项目的离子云使用Yeoman Ionic创建
如何在AngularJs中使用离子云-使用 虽然在angular应用程序中使用Ionic Cloud服务是直截了当的,但在使用yeoman Ionic generator生成的应用程序中却不起作用。这是因为它所遵循的包装步骤。如何使这些项目与离子云协同工作? 离子平台: 构建、推送、部署和扩展您的Ionic应用程序,这是一种简单的方法。Ionic framework 用于angularjs项目的离子云使用Yeoman Ionic创建,ionic-framework,yeoman,Ionic Framework,Yeoman,如何在AngularJs中使用离子云-使用 虽然在angular应用程序中使用Ionic Cloud服务是直截了当的,但在使用yeoman Ionic generator生成的应用程序中却不起作用。这是因为它所遵循的包装步骤。如何使这些项目与离子云协同工作? 离子平台: 构建、推送、部署和扩展您的Ionic应用程序,这是一种简单的方法。 标题说明: 爱奥尼亚平台是一个用于管理和扩展跨平台移动应用程序的云平台。集成服务使您和您的团队能够高效地构建、部署和增长应用程序 文件目标: Ionic平台与
标题说明: 爱奥尼亚平台是一个用于管理和扩展跨平台移动应用程序的云平台。集成服务使您和您的团队能够高效地构建、部署和增长应用程序 文件目标: Ionic平台与标准的Ionic项目配合良好。但遵循任何非标准目录结构的项目可能会面临一些障碍。本文档提供了在使用Yeoman创建的Ionic项目中使用Ionic平台的步骤 文档范围: 本文档介绍了使用Yeoman创建Ionic项目以及使用Ionic平台Web客户端将其与Ionic平台集成的基本步骤。本文档涵盖了利用离子部署、离子分析和离子推送的基本步骤 目标受众: 本文档的目标受众是Web/Mobile应用程序开发人员,他们具有初学者和专家级别的专业知识,熟悉以下先决条件 先决条件: 在尝试本文档之前,您应该熟悉以下框架/工具
- AngularJs:https://docs.angularjs.org/guide
- IonicFramework:http://ionicframework.com/docs/guide
- 约曼:http://yeoman.io/codelab/index.html
- 离子发生器:https://github.com/diegonetto/generator-ionic
- 离子平台:https://ionic.io/platform
离子骨架发生器 来自Yeoman的Ionic框架生成器,Yeoman是现代Web应用程序的网络脚手架工具 Node.js是一个基于Chrome的V8 JavaScript引擎构建的JavaScript运行时。npm是JavaScript的包管理器。从下载并安装节点(和npm)http://nodejs.org
$ npm install npm –g
$ npm install -g yo
Yeoman帮助您启动新项目,制定最佳实践和工具以帮助您保持高效
$ yo ionic [app-name]
在package.json中,在devdependences中包括以下内容
"grunt-string-replace": "^1.2.1"
"ionic-platform-web-client": "^0.7.1"
在bower.json中,在依赖项中包括以下内容
"grunt-string-replace": "^1.2.1"
"ionic-platform-web-client": "^0.7.1"
在Gruntfile.js中,将脚本文件夹更改为“js”。如果需要,也可以更改index.html
grunt.initConfig({ yeoman: {………… scripts: 'js', ………… } })
然后跑
$ bower install && npm install
$ Grunt serve
$grunt$grunt服务$cordova平台添加android$grunt构建:android--调试
爱奥尼亚平台web客户端 提供与Ionic平台交互的web客户端。 我们需要一些代码让你的应用程序与爱奥尼亚平台对话。我们需要为Ionic应用程序添加Ionic平台web客户端,以与插件和Ionic.io平台接口
$ ionic io init
在app.js中添加“ionic.service.core”模块依赖项。在GrunFile.js中添加grunt任务“ionicSettings”,如下所示
grunt.initConfig({
ionicSettings:JSON.stringify(grunt.file.readJSON('./.io-config.json')),
ionicIoBundlePath:'www/bower_components/ionic-platform-web-client/dist/ionic.io.bundle.min.js',
'string-replace':{
ionicSettings:{
files:{
'<%= ionicIoBundlePath %>':'<%= ionicIoBundlePath %>',
},
options:{
replacements:[
{
pattern:'"IONIC_SETTINGS_STRING_START";"IONIC_SETTINGS_STRING_END"',
replacement:'"IONIC_SETTINGS_STRING_START";var settings =<%= ionicSettings %>; return { get: function(setting) { if (settings[setting]) { return settings[setting]; } return null; } };"IONIC_SETTINGS_STRING_END";'
}
]
}
}
},
copy:{
ionicPlatform:{
expand:true,
cwd:'app/bower_components/ionic-platform-web-client/dist/',
src:[
'**'
],
dest:'www/bower_components/ionic-platform-web-client/dist'
}
}
});grunt.registerTask('ionicSettings',
[
'copy:ionicPlatform',
'string-replace:ionicSettings'
]);
grunt.registerTask('deploy',
function (){
return grunt.task.run( [
'init',
'ionic:upload' + this.args.join()
] );
});
离子部署 向生产应用程序推送实时更新,并管理版本历史记录。 Ionic Deploy允许您根据需要更新应用程序,以进行任何不需要二进制修改的更改,从而节省几天甚至几周的等待时间。按照以下步骤为您的应用程序配置Ionic Deploy 在Gruntfile.js中添加grunt任务“deploy”,如下所示
grunt.initConfig({
ionicSettings:JSON.stringify(grunt.file.readJSON('./.io-config.json')),
ionicIoBundlePath:'www/bower_components/ionic-platform-web-client/dist/ionic.io.bundle.min.js',
'string-replace':{
ionicSettings:{
files:{
'<%= ionicIoBundlePath %>':'<%= ionicIoBundlePath %>',
},
options:{
replacements:[
{
pattern:'"IONIC_SETTINGS_STRING_START";"IONIC_SETTINGS_STRING_END"',
replacement:'"IONIC_SETTINGS_STRING_START";var settings =<%= ionicSettings %>; return { get: function(setting) { if (settings[setting]) { return settings[setting]; } return null; } };"IONIC_SETTINGS_STRING_END";'
}
]
}
}
},
copy:{
ionicPlatform:{
expand:true,
cwd:'app/bower_components/ionic-platform-web-client/dist/',
src:[
'**'
],
dest:'www/bower_components/ionic-platform-web-client/dist'
}
}
});grunt.registerTask('ionicSettings',
[
'copy:ionicPlatform',
'string-replace:ionicSettings'
]);
grunt.registerTask('deploy',
function (){
return grunt.task.run( [
'init',
'ionic:upload' + this.args.join()
] );
});
然后跑
$ ionic plugin add ionic-plugin-deploy
$ grunt build:android --debug
离子部署代码:
var deploy = new Ionic.Deploy();// Check Ionic Deploy for new codedeploy.check().then(function(hasUpdate){
},
function(err){
});// Update app code with new release from Ionic Deploydeploy.update().then(function(result){
},
function(error){
},
function(progress){
});
部署更新:
发送应用程序的新代码
创建apk并安装应用程序。对代码进行少量更改,并使用“grunt deploy”部署更改。然后从你的应用程序更新它
您还可以从apps.ionic.io仪表板部署它。您可以在不使用deploy参数的情况下部署应用程序。然后,在仪表板中,您可以添加元数据和版本控制详细信息,并从此处部署应用程序
$ grunt build:android --debug
$ grunt deploy --note "release notes"
$ grunt deploy --note "release notes" --deploy=production
离子分析 查看事件的实时提要或随时间变化的事件/用户的原始/唯一数量。 您的应用程序上现在有多少用户?其中有多少人将在明天或下周使用你的应用程序?如果没有信息,你就无法判断你的应用程序是否以你期望的方式使用。按照以下步骤为您的应用程序配置Ionic Analytics 在你的app.js中,在ionic.service.core之后添加'ionic.service.analytics'模块依赖项
在模块的运行函数中运行analytics register方法
$ionicAnalytics.register();
在Ionic Analytics中,用户在应用程序中进行的每个跟踪操作都由一个事件对象表示。事件是在特定时间点执行的单个操作。要跟踪您自己的事件,请在每次操作发生时调用$ionicAnalytics.track(eventType,eventData)
$ionicAnalytics.track('User Login', { user: $scope.user});
ion track tap指令在其主机元素被轻触时发送事件。关联的离子轨迹数据指令附加事件数据
<button ion-track-tap="eventType" ion-track-data="expression"></button>
然后跑
$ ionic plugin add ionic-plugin-deploy
$ grunt build:android --debug
Ionic Push允许您通过仪表板创建目标推送通知。您还可以使用以下格式从服务器发送通知
curl -X POST -H "Authorization:Bearer API_TOKEN" -H "Content-Type:application/json" -d '{
"tokens":[
"DEVICE_TOKEN"
],
"profile":"PROFILE_TAG",
"notification":{
"message":"Hello World!" "android":{
"title":"Hi User",
"message":"An update is available for your App",
"payload":{
"update":true
}
}
}
}'"https://api.ionic.io/push/notifications"
注意:配置Ionic Push for iOS的步骤与创建推送配置文件的步骤相同。要创建iOS推送配置文件,请参阅http://docs.ionic.io/v2.0.0-beta/docs/ios-push-profiles