简体   繁体   English

实施Urban Airship(Android)获取空APID

[英]Implementing Urban Airship(Android) Getting Null APID

This is my first time ever using UA and I am trying to use push notifications. 这是我第一次使用UA,并且尝试使用推送通知。 Except I keep getting a null APID. 除了我不断得到一个空的APID。 I am also getting an INVALID_USER error from GCM. 我也从GCM收到INVALID_USER错误。 Here is my code: 这是我的代码:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tab);

    AirshipConfigOptions options = AirshipConfigOptions.loadDefaultOptions(this);
    UAirship.takeOff(this.getApplication(), options);
    PushManager.enablePush();

    String apid = PushManager.shared().getAPID();
    Logger.info("My Application onCreate - App APID: " + apid);

Here is the null APID from the log: 这是日志中的空APID:

06-30 19:38:29.118  15793-15793/us.bisonsoftware.tab I/Husky Athletics - UALib﹕ My Application onCreate - App APID: null

And here is the error for the GCM thing: 这是GCM的错误:

06-30 19:38:34.258  15793-16237/us.bisonsoftware.tab E/Husky Athletics - UALib﹕ Received   GCM error: INVALID_SENDER
06-30 19:38:34.258  15793-16237/us.bisonsoftware.tab E/Husky Athletics - UALib﹕ Failed to register with GCM.
06-30 19:38:34.258  15793-16237/us.bisonsoftware.tab E/Husky Athletics - UALib﹕ GCM Failure: INVALID_SENDER
06-30 19:38:34.258  15793-16237/us.bisonsoftware.tab E/Husky Athletics - UALib﹕ Your GCM sender ID is invalid. Please check your AirshipConfig.

I know for the GCM thing it says to check the airship config but I'm not totally sure what the GCM sender ID is. 对于GCM,我知道它说要检查飞艇配置,但我不确定GCM发送者ID是什么。 If anyone could help me with either of these problems it would be much appreciated. 如果有人可以帮助我解决上述任何一个问题,将不胜感激。 Please give details if you know what is wrong since I'm new to this, thanks. 如果您知道出了什么问题是我的新手,请提供详细信息,谢谢。

Your sender ID is the same as your project ID in the Google Cloud/API console. 您的发件人ID与Google Cloud / API控制台中的项目ID相同。 You must configure it in your airshipconfig.properties file: 您必须在airshipconfig.properties文件中进行配置:

gcmSender = Your Google API Project Number (allows multiple senders separated by commas)
developmentAppKey = Your Development App Key
developmentAppSecret = Your Development App Secret
productionAppKey = Your Production App Key
productionAppSecret = Your Production App Secret
inProduction = false
// Testing channel ID
    String channelId = UAirship.shared().getPushManager().getChannelId();
    Logger.info("My Application Channel ID: " + channelId);

Use the above code to get the AppId. 使用上面的代码获取AppId。

There documentation states this : 有文档指出:

Android APIDs have been updated to the latest infrastructure and are now known as Android Channels. Android APID已更新为最新的基础架构,现在称为Android Channels。 All IDs remain the same, so you can start using the Channel term without updating your database. 所有ID保持不变,因此您可以开始使用Channel术语,而无需更新数据库。

Conceptually, Channels are a similar solution to our Windows push systems in the sense that the Channel is an abstraction of the underlying device identifier. 从概念上讲,从某种意义上讲,通道是基础设备标识符的抽象,通道是与Windows推送系统类似的解决方案。 In the case of Windows, the APID serves a similar purpose. 对于Windows,APID具有类似的用途。

http://docs.urbanairship.com/topic_guides/channels.html http://docs.urbanairship.com/topic_guides/channels.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM