簡體   English   中英

客戶端的應用程序是否由BroadcastReceiver從GCM接收到的令牌不能被同一設備上的其他應用程序捕獲?

[英]Is the token which client's app receives by a BroadcastReceiver from GCM can't be captured by other applications on same device?

我只是想知道GCM何時將令牌發送到我的應用程序,同一設備上的其他任何應用程序都可以接收嗎? 每次啟動應用程序時,我應該將其保存在暴民內存中還是要求一個新的?

不建議使用GCM register() 使用實例ID代替它。

什么是實例ID?

實例ID為您的Android和iOS應用的每個實例提供唯一的ID。

主要特征

除了提供唯一的身份驗證ID外,實例ID還可生成安全令牌以與其他服務一起使用。

實例ID生命周期

當您的應用在線時,實例ID服務會發出一個InstanceID。

InstanceID由具有存儲在本地設備上的私鑰和在Instance ID服務中注冊的公鑰的公/私鑰對支持。

您的應用可以在需要時使用getID()方法請求一個新的InstanceID。 如果您有支持應用程序的應用程序,則可以將其存儲在服務器上。

您的應用程序可以根據需要使用getToken()方法從實例ID服務請求令牌,並且與實例ID一樣,您的應用程序也可以將令牌存儲在您自己的服務器上。 發行給您應用的所有令牌均屬於該應用的InstanceID。

令牌是唯一且安全的, but your app or the Instance ID service may need to refresh tokens in the event of a security issue or when a user uninstalls and reinstalls your app during device restoration. Your app must implement a listener to respond to token refresh requests from the Instance ID service. ,則but your app or the Instance ID service may need to refresh tokens in the event of a security issue or when a user uninstalls and reinstalls your app during device restoration. Your app must implement a listener to respond to token refresh requests from the Instance ID service. but your app or the Instance ID service may need to refresh tokens in the event of a security issue or when a user uninstalls and reinstalls your app during device restoration. Your app must implement a listener to respond to token refresh requests from the Instance ID service.

調用instanceId.getToken(...)僅將令牌返回到您的應用程序。 這應該發送到您的應用程序服務器,以用於使用特定令牌將消息發送到應用程序。

無需保存它,實際上不鼓勵保存它。 如果出於某種原因再次需要令牌,則一旦應用程序的相同實例存在(即沒有新安裝)並且未將令牌視為令牌,則始終可以再次調用instanceId.getToken(...)以獲取相同的令牌。被Google入侵,那么您將獲得相同的令牌。

建議您保存一個布爾值,指示您是否已將令牌發送到應用程序服務器,一旦應用程序服務器擁有了令牌,就不必再次生成令牌。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM