本文介绍了如何获得测试GCM令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经实现了网关服务和推送管理器服务,以将推送消息发送到GCM.现在我们要进行一些自动化测试.

We have implemented a gateway service and push manager services to send push messages to GCM.Now we want to do some automated testing.

我们如何测试GCM令牌?

How we can test GCM tokens?

我们可以从真实设备中获取一些令牌,一段时间后它们可能会过期并且测试将失败.为了测试正面和负面的情况,我们需要已知的有效和无效GCM令牌.

We can get some tokens from real devices and after sometime they might expire and tests will fail. To test positive and negative scenarios we need known valid and invalid GCM tokens.

有没有帮助的人?

谢谢.

推荐答案

好的,所以我可能误解了这个问题,以为您在问如何测试注册令牌.

Okay, so I may have misunderstood the question, thinking that you were asking how to test registration tokens.

如果通过测试GCM令牌表示您是注册令牌,则通常是在安装应用后生成的.话虽如此,您不仅在使用设备时会收到它们,而且在使用仿真器时也会得到一个(我一直在使用它来进行测试).

If by test GCM tokens you mean the registration tokens, it is commonly generated upon app installation. With that said, you don't only receive them when using devices, you can also get one when using an emulator (I for one use it all the time for testing).

有效,这一步很简单.安装时提示的第一个令牌应该很好.

For valid, this one is pretty simple. First token you het upon installation should be good.

对于无效的令牌,我认为不是令牌的任何内容(随机字符串和填充物)都将被视为无效.不过,有一件事情是过期的令牌,其中您必须强制调用onTokenRefresh()来生成新的令牌,从而使旧的令牌过期.

For invalid tokens, I think anything that isn't a token (random string and stuff) will be treated as invalid. One thing though is expired tokens, wherein you have to force call the onTokenRefresh() to generate a new one, making the old one expired.

这篇关于如何获得测试GCM令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 08:25