Push Notification in iOS Using Appcelerator Cloud Service
We can implement Push Notification in iOS using Appcelerator Cloud
- Service in 5 steps.
- Cloud User Login
- Retrieve Device Token
- Subscribe a Channel
- Push Certificates
- Push Configuration
1)Cloud User Login
Create a test user in Appcelerator Cloud Console
My Apps -> Manage ACS -> DEVELOPMENT -> Users
and login with credential. Use below code for cloud user login
var Cloud = require('ti.cloud');
Cloud.Users.login({
login: 'push123',
password: 'push123'
}, function (e) {
if (e.success) {
var user = e.users[0];
alert("Loggin successfully");
} else {
alert("Error :"+e.message);
}
});
2)Retrieve Device Token
You can Retrieve Device Token using below code
Titanium.Network.registerForPushNotifications({
types: [
Titanium.Network.NOTIFICATION_TYPE_BADGE,
Titanium.Network.NOTIFICATION_TYPE_ALERT,
Titanium.Network.NOTIFICATION_TYPE_SOUND
],
success:function(e)
{
deviceToken = e.deviceToken;
alert("deviceToken = "+deviceToken);
registerForPush();
},
error:function(e)
{
alert("Error: "+e.message);
},
callback:function(e)
{
alert("push notification received"+JSON.stringify(e.data));
}
});
3)Subscribe a Channel
Add following code for channel subscribtion
Cloud.PushNotifications.subscribe({
channel: 'demo_alert',
type:'ios',
device_token: deviceToken
}, function (e) {
if (e.success) {
alert('Success :'+((e.error && e.message) || JSON.stringify(e)));
} else {
alert('Error:' + ((e.error && e.message) || JSON.stringify(e)));
}
});
4)Push Certificates
It is most important part of this Tutotial, Appcelerator Doc clearly expained about how to create push certificates.
http://cloud.appcelerator.com/docs/ios#push
Follow this section("
Provisioning your Device for specialized Development") to create Development and Production Push certificates. Your certificates should be in .p12 format.
5)Push Configuration
After getting the push certificates(in my case I have created development push certificate), upload it in cloud console.
My Apps -> Manage ACS -> DEVELOPMENT -> Settings -> Apple iOS Push Certificates
Cool.., You have completed Push Notification setup. This time for testing, run the application in iOS device and click the button "
REGISTER PUSH NOTIFICATION". You will get 3 alerts continuously.
Then go to M
y Apps -> Manage ACS -> DEVELOPMENT -> Push Notifications, here you can see "
1 iOS clients subscribed to push notifications"
It is time to send push notification, enter the values and hit the button "
Send Push Notification" instantly you will receive notification in your iOS device(with default icon and sound)
Push Notification in iPad
Push Notification Callback
Here you can download the complete working project from my Github
Appcelerator Titanium iOS Push Notification
原文:
这里
- 大小: 16 KB
- 大小: 16.9 KB
- 大小: 20.9 KB
- 大小: 96 KB
- 大小: 65.2 KB
分享到:
相关推荐
Appcelerator-Cloud-REST-SDK 一个帮助程序类,使您可以轻松地使用REST... 使用Cloud#api()方法例子: $ ACS -> api ( "/push_notification/notify" , "POST" , array ( "channel" => "free_channel" , "payload" =
红混 一个有趣且友好的 Appcelerator Cloud MBaaS 命令行。安装$ [sudo] npm install redmix -g用法获取所有可用的命令和选项: $ redmix help:wine_glass: Redmix « A fun and friendly Appcelerator Cloud MBaaS ...
这里的概念旨在作为我在 Appcelerator Alloy 和 Appcelerator Cloud Services 一书中涵盖的概念的介绍性指南 ##### 这个 repo 的目的是提供一个应用程序模板作为在 Appcelerator Platform 上构建原生、跨平台、支持...
[Packt Publishing] Appcelerator Titanium 移动应用开发教程 (英文版) [Packt Publishing] Creating Mobile Apps with Appcelerator Titanium (E-Book) ☆ 图书概要:☆ Develop fully-featured mobile ...
[Packt Publishing] Appcelerator Titanium 商业应用开发经典实例 (英文版) [Packt Publishing] Appcelerator Titanium Business Application Development Cookbook (E-Book) ☆ 出版信息:☆ [作者信息] ...
In this book you'll learn how to take your existing web knowledge, and adjust your thinking to make the shift from the browser to native mobile app. Table of Contents Chapter 1 Meet the Appcelerator...
Appcelerator 云服务 Titanium Alloy 示例应用程序这里的概念旨在作为我在 Appcelerator Alloy 和 Appcelerator Cloud Services 一书中涵盖的概念的介绍性指南#####这个 repo 的目的是提供一个应用程序模板作为在 ...
jsca2js, 在Appcelerator格式的JSCA格式中,用于转换JSON的实用工具 jsca2js这个项目提供了一组实用工具来将用 JSCA 规范编写的api转换成JSDoc注释的JavaScript文件。对于 these Titanium ,可以在 ide such / 2或者...
cuacfm-ios-appcelerator-iphone IOS应用程序可收听ACoruña的CUAC FM社区广播并从电台播客 该应用程序的屏幕截图
NULL 博文链接:https://eonbell.iteye.com/blog/853810
NULL 博文链接:https://rensanning.iteye.com/blog/1463904
Atom-atom-appcelerator-titanium.zip,用于atom文本编辑器的appcelerator开发工具和ui包原子加速器钛包,atom是一个用web技术构建的开源文本编辑器。
此模块是Axway Appcelerator,Inc.版权所有(c)2010-至今。保留所有权利。 此模块的使用受与Appcelerator,Inc.签订的服务条款协议的约束。 例子 请检查iphone/example/app.js的演示以使用此模块。
titanium-appcelerator-progress-view, 在 Titanium Appcelerator项目中,要使用的自定义进度视图 进度视图这是一个进度视图,显示你的应用程序的某些状态。 你可以设置加载,成功和错误状态。只使用三行代码,你就...
Appcelerator_test Appcelerator_test
NappSlideMenu, Appcelerator Titanium的新UI组件 NappSlideMenu模块描述NappSlideMenu MODULE 扩展了 Appcelerator Titanium Mobile 框架。 MODULE 是在MIT许可证下许可的。感谢 Tom Adriaenssen 在
Appcelerator 云服务 Titanium Alloy Starter App 模板这里的概念旨在作为我在 Appcelerator Alloy 和 Appcelerator Cloud Services 一书中涵盖的概念的介绍性指南#####这个 repo 的目的是提供一个应用程序模板作为...
这里的概念旨在作为我在 Appcelerator Alloy 和 Appcelerator Cloud Services 一书中涵盖的概念的介绍性指南 ##### ###Getting Started 请通过修改项目的app\lib目录中的文件来设置您的常量 修改下面的代码以使用来
该项目构建为在开发期间作为独立的 Node 服务器运行,并且还配置为在 Appcelerator Cloud Services (ACS) 平台上运行。 开始 首先,您应该确保您的环境已设置并准备就绪。 首先,让我们确保您可以运行项目、查看...