让你的Titanium应用也能实现Push的功能吧。
1)申请证书(.p12文件) http://developer.apple.com/devcenter/ios/index.action
Log into Apple's provisioning portal and create a new appid. Take note of your bundle identifier or appid, use the same one form the last step
When you create your application, you need to configure it and enable push notifications. In your application list, click configure for the app you just created.
Now check the box to enable the notification service and click the configure box next to "Development Push SSL Certificate". Note that usually you setup 2 different certificates - one for development and one for production. This maps directly to your development provisioning profile and distribution provisioning profile.
This will prompt us for a certificate
On your machine, open up your keychain and then click "Request a Certificate from a Certificate Authority..."
Put in your email address and common name and make sure that you check "Saved to disk"
Now in your browser, select the certificate request we just generated and submit the request. Once its been uploaded, you will see a status of pending, just refresh until the download button appears.
Click the download button for the certificate and once downloaded to your local machine, open it. This will bring up your keychain app with the certificate listed.
Right click the certificate and click "Export Apple Development Push Services: xxxx"
When you export, p12 format will work just fine (the default)
You will be prompted for a passphrase for the p12 file, you should definitely put something in here (urban airship requires this). Make sure that you take note of the passphrase as we'll need that later
2)将证书放在服务器端的任意文件夹下
3)java版服务器为例,需要的Lib:
apns-0.1.5-jar-with-dependencies.jar
slf4j-simple-1.6.1.jar
代码如下
==================================
【服务器端】
ApnsService service = APNS.newService()
.withCert(CER_PATH, CER_PASS)// CER_PATH是放证书的路劲 CER_PASS是证书的密码
.withSandboxDestination()// 调试模式
//.withProductionDestination() // 产品模式(调试和产品模式只能使用一种)
.build();
String payload = APNS
.newPayload()
.sound("default") // 收到Push信息的声音
.badge(1) // 桌面图标上表示的数字
.alertBody("A: This is a message") // 消息 最大 256bytes(包含自定义变量)
.customField("accountId", "1") // 自定义变量 (可以任意多个)
.build();
// device_token is 64 bytes hex letter.
// device_token indicates a unique user.
service.push(<<device_token>>, payload); // Push Notification。(没有返回值,只能扑捉NetworkIOException来判断异常)
PHP的话可以参考apns-php
【客户端】
Ti.Network.registerForPushNotifications({
types: [
Ti.Network.NOTIFICATION_TYPE_BADGE,
Ti.Network.NOTIFICATION_TYPE_ALERT,
Ti.Network.NOTIFICATION_TYPE_SOUND
],
success:function(e) {
Ti.API.debug("Push Notification success: " + JSON.stringify(e));
var deviceToken = e.deviceToken;
Ti.API.debug('successfully registered for apple device token with '+ deviceToken);
Ti.App.Properties.setString(KEY_DEVICE_TOKEN, deviceToken);
},
error:function(e) {
Ti.API.warn("push notifications disabled: "+ JSON.stringify(e));
},
callback:function(e) {
// 处理接收到的消息
processNotification(e);
}
});
这里有一篇文章是介绍iPhone Push的。
iPhone的Push(推送通知)功能原理浅析
关于Android版的Push机能
=============================================
在Android 2.2版本FroYo之前, Google的Push机制直接就是利用XMPP协议的extension,也就是在<message>元素下加入自定义的子元素, 但自从FroYo, Android引入了一个新的框架C2DM(Cloud to Device Messaging), 而Google的Pushing 机制变成使用C2DM框架.
相关的介绍:
通过代码及流程图说明Google在Android上的Push机制的实现
- 大小: 16.6 KB
- 大小: 66.9 KB
- 大小: 15.3 KB
- 大小: 34.2 KB
- 大小: 111.7 KB
- 大小: 137.8 KB
- 大小: 69.5 KB
- 大小: 27.4 KB
- 大小: 43.5 KB
- 大小: 129.6 KB
- 大小: 65.8 KB
- 大小: 19.6 KB
- 大小: 129.6 KB
分享到:
相关推荐
NappAppearance, 在 Titanium UI组件上,使用 iOS UIAppearance的功能 Napp外观描述Napp外观模块使用全局样式功能扩展了 Appcelerator Titanium Mobile 框架。 Napp外观在 Titanium 用户界面组件上使用 iOS ...
Titanium iOS通知 在Titanium中使用iOS Notifications API(本地,远程,静默和丰富),包括基于Swift的通知扩展!要求7.3.0或更高版本(在GA之前使用appc ti sdk install -b 7_3_X特征 本地通知 远程推送通知 静默...
ActivityIndicator_Titanium-JS 可在iOS和Android上用于Titanium应用程序的活动指示器用法如何为Titanium应用程序使用ANActivityIndicator。 该示例假定您将文件导入到根文件夹中。 var ANActivityIndicator...
在Mac上搭建Titanium的iOS开发环境
Appcelerator Titanium中的本机GoogleMaps iOS SDK 概括 Ti.GoogleMaps是一个开源项目,旨在支持Appcelerator的Titanium Mobile中的Google Maps iOS-SDK。 该模块当前支持以下API: 地图检视 注解 瓷砖覆盖 ...
NULL 博文链接:https://rensanning.iteye.com/blog/1325014
titanium_module_alipay_ios 支付宝的titanium module for ios 作者刘明星 本模块实现了支付宝手机支付sdk的封装,避免了wap支付接口每次支付还需要输入支付宝账号的麻烦。用本地sdk支付仅需要输入6位数字密码即可,...
TiInspector, 通过 Chrome DevTools调试 Titanium Mobile 应用程序 #Ti 检查器Ti检查器允许在 Chrome DevTools web界面中调试 Appcelerator Titanium 应用程序。工具通过将命令和消息转换为 Chrome 调试协议和 ...
[Packt Publishing] Appcelerator Titanium 移动应用开发教程 (英文版) [Packt Publishing] Creating Mobile Apps with Appcelerator Titanium (E-Book) ☆ 图书概要:☆ Develop fully-featured mobile ...
这是一个适用于 iOS (iPhone/iPad) 的 Titanium Mobile 模块,它允许在您的应用程序中内置一个 HTTP 网络服务器。 基本安装说明 请遵循提供的指南。 变更日志 见。 访问保管箱模块 要从 JavaScript 访问此模块,您...
Google-Cloud-Messaging--Titanium-, 在 Titanium 中,Google云消息传递 Google-Cloud-Messaging--Titanium -注册带有GCM和处理发送到设备的通知的Titanium MODULE 。Android平台使用c2dm进行推送,但是因为c2dm停止...
NULL 博文链接:https://rensanning.iteye.com/blog/1388661
这是一个适用于 iOS (iPhone/iPad) 的 Titanium Mobile 模块,允许在 Titanium 项目上使用官方 Dropbox SDK 的全部功能。 可以在找到官方 Dropbox SDK。 基本安装说明 请遵循提供的指南。 此外,请遵循以下附加...
Appcelerator Titanium中的Crashlytics 使用Appcelerator Titanium... 尽管这可能不会导致iOS崩溃,但由于需要本机Activity如果在应用程序完成启动之前使用本机Android SDK,则会出错。 重大变化! 2.0.0版模块使用F
Appcelerator Titanium中的蓝牙 概括 Ti.Bluetooth是一个开放源代码项目,旨在支持Appcelerator Titanium中的Bluetooth / BLE。 要求 适用于Android的Titanium SDK 7+ 适用于iOS的Titanium SDK 8+ iOS 10.0以上/ ...
Appcelerator Titanium中的PayPal iOS SDK 概括 Ti.PayPal是一个开源项目,旨在支持Appcelerator的Titanium Mobile中的PayPal iOS-SDK2.x。 该模块当前支持以下API: 简单付款 未来付款 商家配置 注意:这是Ti....
在Appcelerator Titanium中使用iOS 12+ CarPlay框架。 要求 Titanium SDK 7.3.0以上 iOS 12以上 Xcode 10以上 特征 从您的CarPlay实例接收事件 当前特定于CarPlay的用户界面 使用地图模板从CarPlay开始旅程 ...
TiJSPDF, Titanium Mobile 应用程序的JSPDF插件 TiJSPDFTiJSPDF是用于使用JSPDF库生成pdf并在 Titanium Mobile 应用程序中操作它们的Titanium Mobile 应用程序的一种 JSPDF插件插件。这个插件独立于 Titanium 维护,...
在 Appcelerator Titanium 中查看对话框概括使用SKStoreReviewController从iOS的10.3 +在Ttanium应用。 还可以使用本机 Android 对话框以获得最佳奇偶校验。要求钛移动SDK 8+ iOS 10.3+ 安卓 4.4+安卓使用 import ...
[✔]发送备份(至电子邮件/云)并在1中单击导入 [✔]备份→验证→卸载一口气的应用程序 [✔]只需单击即可冻结/解冻/启动应用程序。 [✔] CSV导出任何应用程序数据库(电子邮件或Google文档)。 [✔]将应用程序...