简体   繁体   中英

Implementing Urban Airship(Android) Getting Null APID

This is my first time ever using UA and I am trying to use push notifications. Except I keep getting a null APID. I am also getting an INVALID_USER error from GCM. 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:

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:

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. 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. You must configure it in your airshipconfig.properties file:

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.

There documentation states this :

Android APIDs have been updated to the latest infrastructure and are now known as Android Channels. All IDs remain the same, so you can start using the Channel term without updating your database.

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. In the case of Windows, the APID serves a similar purpose.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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