LAMP Consortium

Help with sending notifications to Andorid

I’ve been testing sending notifications – using the following code to get a Device ID for a participant:

def get_device(participant_id):
    analytics = LAMP.SensorEvent.all_by_participant(participant_id, origin="lamp.analytics")['data'] 
    all_devices = [event['data'] for event in analytics if 'device_token' in event['data']]
    if len(all_devices) == 0:
        return None 
    else:
        device = f"{'apns' if all_devices[0]['device_type'] == 'iOS' else 'gcm'}:{all_devices[0]['device_token']}" 
        return device

What I’ve found is that the iOS devices seem to work fine – e.g. as soon as someone logs into the app on their iOS device – I’m able to run this and retrieve their Device ID straight away.

However, with an Android device, whenever a user logs in – the device ID never appears to be recorded. No matter how many times they log in or what permissions the app is set to run with on the user’s device. If tested this with a couple of different Android devices to no avail. I did notice a message relating to this on the discourse group about this issue (typically can’t find it now!) but the answer suggested that the latest release of the Android app should fix the problem.

I’ve checked the Google Play Store and it looks like the last update to the app was on December 15th 2020.

Is this the correct way to retrieve the data for an Android Device and are you able to demonstrate how to get a device ID for a Android device user?

Hi @jwbluef ,

Login events look different between android and ios devices, so you may want to look at the list of analytics events with origin = “lamp.analytics”, which is a parameter in lamp.sensorevents

It is possible this is because android also has not been updated in some time. We are working on getting this up to date as soon as possible. Thank you so much for your patience!