How to get test GCM tokens?

2019-09-11 12:42发布

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

How we can test GCM tokens?

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.

Any help guys?

Thanks.

1条回答
够拽才男人
2楼-- · 2019-09-11 13:00

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

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.

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.

查看更多
登录 后发表回答