Closed dillonhubble closed 4 years ago
Based on Apple's docs found in their Local and Remote Notification Programming Guide device tokens can be a variable length, so we shouldn't hardcode the length.
That means that the code in api/tokens.py on line 73 needs to be changed, as well as api/init.py from line 94 and api/init.py line 255. Moodle determines the device type, so we should just use that value being passed by Moodle rather than determine the device type by the length of the device token.
Hi dillonhubble
I'm also using moodle and getting invalid token errors. However, my tokens are the expected 64 characters. I've been testing direct pushes with NWPusher and the token in the moodle db works when I use NWPusher on it.
Hi @mugwhump
I resolved this by only using Firebase. I realised that Firebase has an iOS section as well. So all you need to do is set up your Airnotifier connection to FCM (Firebase) and then upload your APN certificates (from the Apple Developer console) to Firebase as well.
That way Firebase handles all the push notifications for both Android and iOS and you don't have to worry too much about it.
You will then also need to make changes to the airnotifier code so that the conditions cater for both FCM and iOS, e.g. the line here should have the constants ANDROID and IOS so that regardless of the device, it sends to the same Firebase endpoint. You'll have to make this change throughout Airnotifier. I unfortunately couldn't get iOS in Airnotifier to work properly.
I hope this helps.
@dillonhubble that line has been updated in 2.x branch: https://github.com/airnotifier/airnotifier/blob/2.x/api/push.py#L111
Hi
I have a Moodle LMS on version 3.5 and an Airnotifer Server running the latest FCM branch version.
I've uploaded the APN certificates and it shows that it is online, but I get an error of "Invalid token" when sending a message from my LMS.
When looking at the code in api/tokens.py, I see conditions looking for
if len(devicetoken) != 64:
, however, in my Moodle DB, I have Apple devices with pushid's much larger than 64 characters.It works with Android.
What can I do to fix this?