I have an iOS application where I want to add push notifications. I also setup a Django backend for the app. I want to send push notifications from the Django backend to the iOS app for specific users.
I successfully setup Firebase Messaging and am receiving the push notifications on the mobile app when I create one through the FireBase dashboard. However, I am incredible confused on how I can achieve this through the backend.
I am using the Django-push-notifications app from Github
I have setup the settings as follows:
INSTALLED_APPS = (
...
"push_notifications"
)
PUSH_NOTIFICATIONS_SETTINGS = {
"FCM_API_KEY": os.environ.get('FCM_API_KEY', "AAAAA"),
"APNS_AUTH_KEY_PATH": "/MYkey.p8",
"APNS_AUTH_KEY_ID": os.environ.get('APNS_AUTH_KEY_ID', "AAAAA"),
"APNS_TEAM_ID": os.environ.get('APNS_TEAM_ID', "AAAAA"),
}
I don't manually use the APNS tokens. I use the FCM tokens to send a message to a specific user in the dashboard of FireBase. However, I am not aware that Firebase is using any APNS tokens (but it must I suppose). This topic just adds to the confusion since APNS tokens aren't necessarily tied to the retrieval of FCM tokens.
From what I gather I should use the following code to send a message:
from push_notifications.models import APNSDevice
device = APNSDevice.objects.get(registration_id=apns_token)
device.send_message(message={"title" : "Game Request", "body" : "Bob wants to play poker"}, extra={"foo": "bar"})
It asks for the APNS_Token. I can't manually fill it in and should retrieve it somehow. My understanding was that I send a push request to Firebase which in turn will use the configured settings to push that message to my iPhone.
So Django -> FireBase -> iOS App
Youtube does not have a single tutorial for my specific use case which I thought would be pretty popular. There are some tutorials online but they show both Android and iOS. Android being from google the terminology is a bit confusing as I don't know whether some settings need to be used for firebase or android. Both from google services of course.
Anyone some input on this predicament?