In file included from /Users/lee/temp/PushNotificationsDemo/Source/Main.cpp:10:
/Users/lee/temp/PushNotificationsDemo/Source/PushNotificationsDemo.h:263:25: error: no viable overloaded ‘=’
n.publicVersion = new PushNotifications::Notification();
~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I commented this out to continue, but when proceeding, deviceTokenRefreshed() never gets called and calling getDeviceToken() always returns an empty string.
In addition, the app never registers with firebase:
I’ll get that sorted out. It just needs to be changed to n.publicVersion.reset (new PushNotifications::Notification()); - it must have been missed when we migrated from juce::ScopedPointer to std::unique_ptr.
Yes, I’ve been through it in detail and I just cannot get it to work. Unfortunately the tutorial doesn’t cover troubleshooting of any kind, it just assumes everything works - really, as this involves config on another system it would be useful to have things like “if you never receive a token, check…”. Ideally vid tutorials would handle this topic much better (I also think the tutorial could be better organised and just have iOS in one go, Android in one go and MacOs in one go rather than jumping around between them). (The iOS stuff is fine, but pretty useless as in reality you need to be able to use it with Firebase too). I can’t get either iOS (some objective-C is needed to be written into your app and I don’t know where to do this as I’m not an objective-C person) and Android apps just never seem to receive the token (either my own, or the PushNotificationsDemo).
It would be really helpful if the creator of the tutorial could go through it and confirm that following the steps, they are able to successfully connect the PushNotificationsDemo program to Firebase and have it receive tokens etc.
Hi, I’ve looked into the code and a lot of the PushNotifications for Android does nothing unless:
JUCE_FIREBASE_INSTANCE_ID_SERVICE_CLASSNAME
is defined. I can’t see any mention of this #define and it’s not automatically done in my projects through Projucer that I can see. If I enable this flag then nothing builds anymore.
Thank you both for raising this and for your patience. PushNotifications were indeed broken while reworking Android internals and they are now fixed in commit 7c46014
We have also added explanations to PushNotificationsDemo with all the steps that are required to make local and remote notifications work:
Let us know if there is anything that is unclear. When pulling from develop, remember to rebuild Projucer. To verify that everything works, you can fire up the PushNotificationsDemo, go to Remote tab and press “GetDeviceToken” button, you will get the dialog with your token, also displayed in the console in debug builds:
Then after launching the app go to Firebase Console and send a test message to your device using the token received:
* App deletes Instance ID
* App is restored on a new device
* User uninstalls/reinstall the app
* User clears app data
it is odd that it only started crashing later, the crash would suggest that there is something wrong with the passed token. You get the crash after clean install because that’s when the token gets refreshed and the crashing line gets triggered. On successive start of the app you will not get the notification. Do you test it on a real device? What Android version is it? Please try the following fix and let me know if it works for you (uninstall and reinstall the app, and make sure that this line is definitely called after changing the code):
So I came back into the office and I can’t reproduce the problem anymore. I might have used the old version of projucer by accident. If the problem occurs again I will try your change. Thanks for the help!
I’m trying to get Firebase up and running on iOS also but need to perform this step of adding this to my project, but not sure how/where to do this as not an obj-C programmer. Any ideas? thx
You need to use START_JUCE_APPLICATION_WITH_CUSTOM_DELEGATE macro stating your custom UIApplicationDelegate implementation, then you need to implement that delegate in ObjC
Here’s a barebone implementation which calls the function you need and it also instantiates JUCE’s delegate internally. Note that we need to be forwarding messages to JUCE delegate so that JUCE can do its things as usual.