0
我正在嘗試將GCM
集成到鈦加速器中。找到用於GCM集成的不兼容鈦模塊
我在我的鈦項目中整合了net.iamyellow.gcmjs模塊。但得到以下錯誤。
[錯誤]:發現不兼容的鈦模塊:[錯誤]:ID: net.iamyellow.gcmjs版本:0.2平臺:Android的SDK分鐘: 3.0.2.GA
和我titanium SDK
版本是6.1.2.GA
。
我正在嘗試將GCM
集成到鈦加速器中。找到用於GCM集成的不兼容鈦模塊
我在我的鈦項目中整合了net.iamyellow.gcmjs模塊。但得到以下錯誤。
[錯誤]:發現不兼容的鈦模塊:[錯誤]:ID: net.iamyellow.gcmjs版本:0.2平臺:Android的SDK分鐘: 3.0.2.GA
和我titanium SDK
版本是6.1.2.GA
。
爲了幫助您入門,here are some good guidelines。另外,你會找到一些代碼示例,它們會幫助你,或者至少讓你知道你的代碼有什麼問題,以及它爲什麼會給你那個錯誤。您可以比較網站提供的代碼中的代碼。
讓我們從幾行配置開始。打開Titanium項目的tiapp.xml文件 ,因爲我們需要首先聲明模塊。 完成後,gcm.js只需要一個屬性即可使事情發揮作用:發件人ID爲 。正如你在下面的例子中看到的,只是與信息填入屬性 值:
<property name="GCM_sender_id" type="string">YOUR_SENDER_ID</property>
<modules>
<module platform="android" version="0.2">net.iamyellow.gcmjs</module>
</modules>
現在,在某處你的應用中,您需要註冊它推 通知:
var gcm = require('net.iamyellow.gcmjs')
var pendingData = gcm.data;
if (pendingData && pendingData !== null) {
// if we're here is because user has clicked on the notification
// and we set extras for the intent
// and the app WAS NOT running
// (don't worry, we'll see more of this later)
Ti.API.info('******* data (started) ' + JSON.stringify(pendingData));
}
gcm.registerForPushNotifications({
success: function (ev) {
// on successful registration
Ti.API.info('******* success, ' + ev.deviceToken);
},
error: function (ev) {
// when an error occurs
Ti.API.info('******* error, ' + ev.error);
},
callback: function() {
// when a gcm notification is received WHEN the app IS IN FOREGROUND
alert('hellow yellow!');
},
unregister: function (ev) {
// on unregister
Ti.API.info('******* unregister, ' + ev.deviceToken);
},
data: function (data) {
// if we're here is because user has clicked on the notification
// and we set extras in the intent
// and the app WAS RUNNING (=> RESUMED)
// (again don't worry, we'll see more of this later)
Ti.API.info('******* data (resumed) ' + JSON.stringify(data));
}
});
// in order to unregister:
// require('net.iamyellow.gcmjs').unregister();
只是探索網站有一個擴大視圖的技巧。
希望這會有所幫助。