2016-04-27 92 views

回答

0

您可以使用Instance ID API獲得註冊令牌。 Google提供實例ID API來處理註冊令牌的創建和更新。要使用此API,在清單中包括InstanceIDListenerService

<service android:name="[.MyInstanceIDService]" android:exported="false"> 
    <intent-filter> 
     <action android:name="com.google.android.gms.iid.InstanceID"/> 
    </intent-filter> 
</service> 

To obtain a token,叫instanceID.getToken,提供應用程序服務器的發件人ID和範圍設置爲GoogleCloudMessaging.INSTANCE_ID_SCOPE。不要在主線程中調用此方法;相反,使用擴展IntentService

檢查這個page更多信息的服務。

0

您可以在Android/IOS應用程序中獲取registration_token

在Android應用程序,你可以通過使用得到registration_token ..

gcm_instance_id = GoogleCloudMessaging.getInstance(getApplicationContext()); 
registration_token = gcm_instance_id.register(PROJECT_NUMBER); 

您可以從https://console.developers.google.com/

找到PROJECT_NUMBER然後你可以發送該registration_token到Rails API,並將其存儲到數據庫..

謝謝