Back in October last year, I wrote about integrating iOS support for FCM using Embarcadero’s implementation. In this article, I describe a revised demo that simplifies things and fixes a couple of issues.
STTP
The new demo can be found here. Please be aware that the ShowBannerIfForeground must be set to False if you don’t want a banner showing while the app is in the foreground, and that both data and notification elements must be present for Android push messages when the app is running, for everything to work as expected. See below for more details.
The new demo
The previous demo was basically just an expansion of example code presented by Embarcadero when their support for FCM (Android only) was introduced. The new demo encapsulates that code into its own unit, so all that needs to be done is to create an instance of the class (TPushNotifications) and assign a couple of event handlers.
The issues
Showing a banner when the app is not running
One of the main issues with the FCM implementation for Android is that a banner does not show when the application is not running, i.e. all that shows is the notification icon in the status bar.
The banner shows only if the Importance of the channel is set to High, so the startup code in TPushNotifications creates the channel, and sets the Importance to High. The channel id is extracted from the application metadata (in AndroidManifest.xml) using some code recently introduced into the Kastri Free library (DW.OSMetadata.XXX units).
Much larger issues
There are some extremely annoying quirks with FCM on Android, and I’m hoping I’m just doing something wrong and that someone can point it out, however from what I’ve discovered:
When an app is in the background (i.e. still running, but not in the foreground), in order for a notification to be received, the payload must contain a data element. However, if the app is not running at all, the payload must contain a notification element, otherwise no notification is presented.
In addition, when the app is in the foreground, no banner shows at all. To allow for this, I’ve updated the code to present a local notification, which will show when the ShowBannerIfForeground property of TPushNotifications is set to True. Note that this property applies to Android only, as it works on iOS.
Now all will work as expected, as long as messages sent to Android devices contain both a notification and data element (they can contain the same data).
Configuration
Remember to import your google-services.json file for Android:
..and to provide your Google-Services.info.plist for iOS (for the demo, it will go in the Resources folder)
Sending messages
I’m planning an article which covers creating a server which includes sending messages, however for now for testing you could use the standalone testing tool: PushIt.
As above, messages to Android devices should contain both a notification and a data element for everything to work correctly. Here’s an example payload:
[sourcecode language=”javascript”]
{
"to":"fDYt7NwXGyM:APA91bE_5ACVjyRubh3-s_kRD6Ig83LX8VKcsEFCxIfDemw49AIHudDGVQwnJ5r1UMlPBc2A2P6yrEZ6fbBsejrHaX5vQQ-RdpUbRiRk1UURknTDrJfMIMqkTZGd0mstxLWsMaI-pWjl",
"notification":{
"android_channel_id":"EMBTFCMv2",
"title":"Testing.. 1..2..3..",
"body":"FCM still rules!"
},
"data":{
"android_channel_id":"EMBTFCMv2",
"title":"Testing.. 1..2..3..",
"body":"FCM still rules!"
}
}[/sourcecode]
For iOS, there should be a notification element only.
Conclusion
I sincerely hope that I’ve missed something in regards to what needs to be in the payload to make things work as expected on Android, so if anyone can shed some light on the problem please let me know, however I do know that using the methods above works.
Hi Dave, nice work.
You’ve released ‘FCMRevisited’ in the past. Do you recommend to migrate to the new EMBT-based FCM-implementation?
Hi Pieter,
Thanks! My personal preference is for this new implementation as it does not rely as much on code that is not provided with Delphi (including other .jar files in my original work), however you choose whatever you feel more comfortable with 🙂
Hi Dave,
I get a linker error that /usr/lib/clang/lib/darwin/libclang_rt.ios.a couldn’t be found.
Working on Delphi 10.3.1, iOS SDK 12.2, just updates library cache.
Do I need to upgrade Delphi?
Thanks again!
You should be able to fix it by editing the iOS SDK in the Delphi SDK Manager. In the “Include Paths”, there’s a path to the Clang libraries. It should read:
$(SDKROOT)/../../../../../Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0
Once you’ve edited that, click Update Local File Cache
Ah, I see my XCode 10.2.1 installed clang version 10.0.1.
Reverted back to XCode 10.1.
Linking goes somewhat further. Now breaking on
“[DCC Error] Undefined symbols for architecture arm64:”
“[DCC Fatal Error] Linker error code: 1 ($00000001)”
I do pass “-ObjC” to the LD linker.
Have cleared the project output path.
Apps without FCM link well.
Do you have any idea?
I’m sorry, if you’re using Delphi 10.3, the path should actually be:
$(SDKROOT)/../../../../../Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/$(CLANGVERSION)
You should not need to revert your Xcode version. Regardless, with the “undefined symbols” error, it should actually show which symbols it could not find. Check the Output tab of the Messages window.
First, thanks for your updates. However, I’ve encountered issue in receiving FCM message on iOS11 and iOS12 devices.
I’ve used the EMBTFCMv2 project provided, change the Bundle ID and place my GoogleService-Info.plist under Resource folder. Build and deploy to iPhone and iPad are ok and Firebase token display in the App.
I use the PushIt project provided to send a simple message with the Firebase token got and send with the following json
{
“to”:”fl0lAloa4og:APA91bFiVI0ExmehpFd-kNghAGJJO6CSxO9c9NaGHVv8JR0OiM4sUxo-_MHlyBSd3-uuwN8cfkvLU-HDpzCjmTtpbrnA2B6O0hdUj7lRAF”,
“notification”:{
“title”:”TEST”,
“subtitle”:”TEST Subtitle”,
“body”:”Test body”,
“priority”:”normal”,
“content_available”:true
},
“data”:{
“title”:”TEST”,
“subtitle”:”TEST Subtitle”,
“body”:”Test body”,
“priority”:”normal”,
“content_available”:true
}
}
and the response is success as follow:
{“multicast_id”:8432882091864998877,”success”:1,”failure”:0,”canonical_ids”:0,”results”:[{“message_id”:”0:1578620694998877%c783d000c387d000″}]}
However, my devices never receive the message. I’ve tried with App open in foreground, put it background and kill the app. Also scenarios cannot receive the push notification.
Do you have any way to check the issue?
Thanks.
I’ve also send notification only as below, but still not success.
{
“to”:”fl0lAloa4og:APA91bFiVI0ExmehpFd-kNghAGJJO6CSxO9c9NaGHVv8JR0OiM4sUxo-_MHlyBSd3-uuwN8cfkvLU-HDpzCjmTtpbrnA2B6O0hdUj7lRAF”,
“notification”:{
“title”:”TEST”,
“subtitle”:”TEST Subtitle”,
“body”:”Test body”,
“priority”:”normal”,
“content_available”:true
}
}
Please ensure that the application identifier you created in the Apple Developer portal has Push Notifications enabled, and that your provisioning profile has the correct application identifier associated with it. One way you can tell if everything is correct is that the .entitlements file that is deployed (to the Output Folder in Project Options) will have an aps-environment key in it.
Hi Dave,
Thanks for your prompt reply.
I’ve checked the AppFCM.entitlements file and there missing aps-environment key
application-identifier
FVM48522T6.com.test.AppFMC
get-task-allow
com.apple.developer.team-identifier
FVM48987T6
keychain-access-groups
FVM48987T6.com.test.AppFMC
Is there anything missing so that the aps-environment key is missing.
NB: I’ve just use your project, save as another name and modify the bundle identifier then build to me device.
Further information: My iOS64 device target’s configuration is Development (as I do not have the corresponding profile / certification pairs for AppStore and Adhoc)
Dear Dave,
I’ve checked some other post (https://forums.embarcadero.com/thread.jspa?threadID=248351), it seems to be my profile / certification pairs not having the entitlement for push notification. So my AppFCM.entitlement file will not have the aps-environment key being generated.
I’ll find the appropriate personnel to build the app to test it.
Thanks for your great work.
Sorry for the fomatting. It seems wordpress(??) cannot direct input xml syntax stuff.
Hi Dave,
First, thanks for your updates.
I use the EMBTFCMV2Demo application and everything works fine. I would like to know if it’s possible to open the application upon receipt of a notification. (Currently it displays a notification icon and on a click it opens the application).
Thanks.
> I would like to know if it’s possible to open the application upon receipt of a notification
It should do this already. If not, on which platform(s) does it not occur?
I am with Android 8.1!
Here is my JSON message to send from my server:
{
“to”:”dzRr8LZi3o8:APA91bEr4PbAotRmGDFOpBpzLNJJOTtQ3duXd7WIWf8dLS9KREouD6K0dGVENzQakdGcU_m4TdpMXoL7PcLxe00dTamKMsj03moevTb6ev1QTAtS7HDgdduptQ6YPfo0HX4rXtSWRKm4″,
“message_id”:”9764″,
“notification”:
{
“title”:”aa”,
“subtitle”:”aaa”,
“body”:”aaa”,
“priority”:”high”,
“content_available”:true
},
“data”:
{
“title”:”aa”,
“subtitle”:”aaa”,
“body”:”aaa”,
“priority”:”high”,
“content_available”:true
},
“time_to_live”:60,
“delay_while_idle”: true,
“delivery_receipt_requested”: true
}
Tnank’s
This kind of payload works for me. When the notification is received on the device, I tap it, and the application opens.
For me too, when the notification is received on the device, I tap it, and the application opens, but my question is : is it possible to open “automatically” the application upon receipt of a notification. (when the application is closed)?
Thank you
Hi Dave, I’ve asked you a question in a prior blog post about iOS Notification implementation, and didn’t have the time to come back to it.
My problem was: Device Token would arrive, but the app would never receive any notifications.
After digging in the Device Logs of my iPad I found the following error message:
“[Firebase / Messaging][…] Error in application:didFailToRegisterForRemoteNotificationsWithError: “no valid ‘aps-environment’ entitlement string found for application”
This will happen when using a Wildcard Provisioning profile (as in a profile that looks like: ” com.example.* “).
When I used a profile with a full path (com.example.myapp), it will be able to register itself with the Firebase service.
I hope this will help somebody, as a few persons in this thread already had this error message.
Hi Dave,
After struggling with the Apple Certificates/Profile pairs, finally make my development profile generate the App.entitlements with the app-environmentdevelopment included.
The app can obtain the device token and PushIt reported successful send FCM message.
However, the iOS device still cannot receive Push Notification.
Any idea?
json payload:
{
“to”:”fUkd3co:APA91bFe8Ks0ahN5clXYgdPo-E661WbIrPG10U9d50IseL-DlZ08rq”,
“notification”:{
“title”:”test20200203115″,
“subtitle”:”test”,
“body”:”test body”,
“priority”:”normal”,
“content_available”:true
},
“data”:{
“title”:”test20200203115″,
“subtitle”:”test”,
“body”:”test body”,
“priority”:”normal”,
“content_available”:true
}
}
response:
{“multicast_id”:6460338063574167308,”success”:1,”failure”:0,”canonical_ids”:0,”results”:[{“message_id”:”0:1580699772958440%c783d000c783d000″}]}
Regards,
Alex
Hi Alex,
Does your provisioning profile point to a wildcard name (like ” com.example.* “)? If yes, try using a provisioning profile that uses an explicit name, like com.example.myapp
Sound like you have the same problem as I’ve had.
If that still doesn’t work, try looking into the logs, to see if your app can register itself with the token on the firebase service
(XCode > Window > Devices and Simulators > Click your Device > Open Console)
Finally can make iOS device receive FCM message.
What I’ve done are as follow:
* logon to developer.apple.com
* regenerate profile and apns certificates
* import certificates on Mac’s keychain
* export apns certificates as .p12 by keychain
* logon Firebase console
* upload new apns certificates
* download and include new GoogleService-Info.plist in project
Hi Dave, this is the error.
I went back to XCode 10.2.1.
error E2597: Undefined symbols for architecture arm64:
Error: “_NANOGetArray”, referenced from: -[APMDatabase rawEventDataFromDictionary:error:] in GoogleAppMeasurement(APMDatabase_8fb1462c371134c9e7e904dead1ca2b8.o); -[APMRemoteConfig parseRemoteConfigFromMeasurementConfig:] in GoogleAppMeasurement
Hi Dave,
Upgrading to D10.3.2 didn’t fix the issue.
Could is be a missing imported framework the compiler couldn’t hint about?
The following frameworks I have added manually:
– SystemConfiguration
– AudioToolbox
– ImageIO
– Metal
– IOSurface
Found the solution. My projects were configured with Firebase 5.5.0 in the searchpath. I had to upgrade them to 6.2.0.
Is there still a need for version 5.5.0? If it wasn’t distributed anymore I would have found the problem a lot sooner 😉
Thanks for you help Dave!
Great post,
Got this working within half an hour. Sending from Pushit from windows. Receiving on Android.
However I get the following errors:
1.
Compiling to PushIt to MAC.
Checking project dependencies…
Compiling PushIt.dproj (Debug, OSX64)
brcc32 command line for “PushIt.vrc”
c:\program files (x86)\embarcadero\studio\20.0\bin\cgrc.exe -c65001 PushIt.vrc -foPushIt.res
brcc32 command line for “Styles\Styles.macOS.rc”
c:\program files (x86)\embarcadero\studio\20.0\bin\brcc32.exe -dDEBUG -i”c:\program files (x86)\embarcadero\studio\20.0\lib\OSX64\debug”;”C:\Program
Files (x86)\Steema Software\Steema TeeGrid for VCL & FMX Binary Version 1.09\Compiled\Delphi26.osx64\Lib”;\API;\Core;\Include;
C:\Users\User\Documents\Embarcadero\Studio\20.0\Imports;”c:\program files (x86)\embarcadero\studio\20.0\Imports”;”c:\program files
(x86)\embarcadero\studio\20.0\include”;”C:\Program Files (x86)\Devart\MyDAC for RAD Studio 10.3\Lib\OSX64″;”C:\Program Files (x86)\Devart\MyDAC for
RAD Studio 10.3\Bin\OSX64″;”C:\Program Files (x86)\FastReports\FastReport FMX Embarcadero edition\LibD26OSX64″;”C:\Program Files
(x86)\FastReports\FastReport FMX Embarcadero edition\LibD26OSX64″;D:\techy\delphiComponents\KastriFree-master\Core;
D:\techy\delphiComponents\KastriFree-master\API;D:\techy\delphiComponents\KastriFree-master\include Styles\Styles.macOS.rc -foStyles.macOS.res
brcc32 command line for “Styles\Styles.Default.rc”
c:\program files (x86)\embarcadero\studio\20.0\bin\brcc32.exe -dDEBUG -i”c:\program files (x86)\embarcadero\studio\20.0\lib\OSX64\debug”;”C:\Program
Files (x86)\Steema Software\Steema TeeGrid for VCL & FMX Binary Version 1.09\Compiled\Delphi26.osx64\Lib”;\API;\Core;\Include;
C:\Users\User\Documents\Embarcadero\Studio\20.0\Imports;”c:\program files (x86)\embarcadero\studio\20.0\Imports”;”c:\program files
(x86)\embarcadero\studio\20.0\include”;”C:\Program Files (x86)\Devart\MyDAC for RAD Studio 10.3\Lib\OSX64″;”C:\Program Files (x86)\Devart\MyDAC for
RAD Studio 10.3\Bin\OSX64″;”C:\Program Files (x86)\FastReports\FastReport FMX Embarcadero edition\LibD26OSX64″;”C:\Program Files
(x86)\FastReports\FastReport FMX Embarcadero edition\LibD26OSX64″;D:\techy\delphiComponents\KastriFree-master\Core;
D:\techy\delphiComponents\KastriFree-master\API;D:\techy\delphiComponents\KastriFree-master\include Styles\Styles.Default.rc -foStyles.Default.res
dccosx64 command line for “PushIt.dpr”
c:\program files (x86)\embarcadero\studio\20.0\bin\dccosx64.exe -$O- –no-config -M -Q -AGenerics.Collections=System.Generics.Collections;
Generics.Defaults=System.Generics.Defaults -DDEBUG -E.\OSX64\Debug -I”c:\program files (x86)\embarcadero\studio\20.0\lib\OSX64\debug”;”C:\Program
Files (x86)\Steema Software\Steema TeeGrid for VCL & FMX Binary Version 1.09\Compiled\Delphi26.osx64\Lib”;\API;\Core;\Include;
C:\Users\User\Documents\Embarcadero\Studio\20.0\Imports;”c:\program files (x86)\embarcadero\studio\20.0\Imports”;”c:\program files
(x86)\embarcadero\studio\20.0\include”;”C:\Program Files (x86)\Devart\MyDAC for RAD Studio 10.3\Lib\OSX64″;”C:\Program Files (x86)\Devart\MyDAC for
RAD Studio 10.3\Bin\OSX64″;”C:\Program Files (x86)\FastReports\FastReport FMX Embarcadero edition\LibD26OSX64″;”C:\Program Files
(x86)\FastReports\FastReport FMX Embarcadero edition\LibD26OSX64″;D:\techy\delphiComponents\KastriFree-master\Core;
D:\techy\delphiComponents\KastriFree-master\API;D:\techy\delphiComponents\KastriFree-master\include
-LEC:\Users\Public\Documents\Embarcadero\Studio\20.0\Bpl\OSX64 -LNC:\Users\Public\Documents\Embarcadero\Studio\20.0\Dcp\OSX64 -NU.\OSX64\Debug
-NSSystem;Xml;Data;Datasnap;Web;Soap; -O\API;\Core;\Include;C:\Users\User\Documents\Embarcadero\Studio\20.0\Imports;”c:\program files
(x86)\embarcadero\studio\20.0\Imports”;”c:\program files (x86)\embarcadero\studio\20.0\include”;”C:\Program Files (x86)\Devart\MyDAC for RAD Studio
10.3\Lib\OSX64″;”C:\Program Files (x86)\Devart\MyDAC for RAD Studio 10.3\Bin\OSX64″;”C:\Program Files (x86)\FastReports\FastReport FMX Embarcadero
edition\LibD26OSX64″;”C:\Program Files (x86)\FastReports\FastReport FMX Embarcadero edition\LibD26OSX64″;
D:\techy\delphiComponents\KastriFree-master\Core;D:\techy\delphiComponents\KastriFree-master\API;D:\techy\delphiComponents\KastriFree-master\include
-R\API;\Core;\Include;C:\Users\User\Documents\Embarcadero\Studio\20.0\Imports;”c:\program files (x86)\embarcadero\studio\20.0\Imports”;”c:\program
files (x86)\embarcadero\studio\20.0\include”;”C:\Program Files (x86)\Devart\MyDAC for RAD Studio 10.3\Lib\OSX64″;”C:\Program Files (x86)\Devart\MyDAC
for RAD Studio 10.3\Bin\OSX64″;”C:\Program Files (x86)\FastReports\FastReport FMX Embarcadero edition\LibD26OSX64″;”C:\Program Files
(x86)\FastReports\FastReport FMX Embarcadero edition\LibD26OSX64″;D:\techy\delphiComponents\KastriFree-master\Core;
D:\techy\delphiComponents\KastriFree-master\API;D:\techy\delphiComponents\KastriFree-master\include -U”c:\program files
(x86)\embarcadero\studio\20.0\lib\OSX64\debug”;”C:\Program Files (x86)\Steema Software\Steema TeeGrid for VCL & FMX Binary Version
1.09\Compiled\Delphi26.osx64\Lib”;\API;\Core;\Include;C:\Users\User\Documents\Embarcadero\Studio\20.0\Imports;”c:\program files
(x86)\embarcadero\studio\20.0\Imports”;”c:\program files (x86)\embarcadero\studio\20.0\include”;”C:\Program Files (x86)\Devart\MyDAC for RAD Studio
10.3\Lib\OSX64″;”C:\Program Files (x86)\Devart\MyDAC for RAD Studio 10.3\Bin\OSX64″;”C:\Program Files (x86)\FastReports\FastReport FMX Embarcadero
edition\LibD26OSX64″;”C:\Program Files (x86)\FastReports\FastReport FMX Embarcadero edition\LibD26OSX64″;
D:\techy\delphiComponents\KastriFree-master\Core;D:\techy\delphiComponents\KastriFree-master\API;D:\techy\delphiComponents\KastriFree-master\include
–syslibroot:C:\Users\User\Documents\Embarcadero\Studio\SDKs\MacOSX10.15.sdk
–frameworkpath:C:\Users\User\Documents\Embarcadero\Studio\SDKs\MacOSX10.15.sdk\System\Library\Frameworks;
C:\Users\User\Documents\Embarcadero\Studio\SDKs\MacOSX10.15.sdk\System\Library\PrivateFrameworks -V -VN
-NHC:\Users\Public\Documents\Embarcadero\Studio\20.0\hpp\OSX64 -NO.\OSX64\Debug PushIt.dpr
[dccosx64 Error] E2597 ld: warning: directory not found for option ‘-L\API’
ld: warning: directory not found for option ‘-L\Core’
ld: warning: directory not found for option ‘-L\Include’
ld: file not found: librtlhelper.a
[dccosx64 Fatal Error] F2588 Linker error code: 1 ($00000001)
Failed
Elapsed time: 00:00:02.4
I have added the path to the Mac64Bit Linker ( Same as the windows version )
2.
Compiling EMBTFCMv2Demo to IOS
Checking project dependencies…
Compiling EMBTFCMv2Demo.dproj (Debug, iOSDevice64)
brcc32 command line for “EMBTFCMv2Demo.vrc”
c:\program files (x86)\embarcadero\studio\20.0\bin\cgrc.exe -c65001 EMBTFCMv2Demo.vrc -foEMBTFCMv2Demo.res
dcciosarm64 command line for “EMBTFCMv2Demo.dpr”
c:\program files (x86)\embarcadero\studio\20.0\bin\dcciosarm64.exe -$O- –no-config -M -Q -AGenerics.Collections=System.Generics.Collections;
Generics.Defaults=System.Generics.Defaults -DDEBUG -E.\iOSDevice64\Debug -I”c:\program files (x86)\embarcadero\studio\20.0\lib\iOSDevice64\debug”;
“C:\Program Files (x86)\Steema Software\Steema TeeGrid for VCL & FMX Binary Version 1.09\Compiled\Delphi26.iOSDevice64\Lib”;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\FirebaseAnalytics.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\FirebaseCore.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\FirebaseCoreDiagnostics.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\FirebaseInstanceID.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\GoogleAppMeasurement.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\GoogleUtilities.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\nanoPB.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Messaging\FirebaseMessaging.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Messaging\Protobuf.framework;..\..\API;..\..\Core;..\..\Include;..\..\Features\Firebase;
..\..\Features\Notifications;”c:\program files (x86)\embarcadero\studio\20.0\lib\iOSDevice64\Release”;”C:\Program Files (x86)\Devart\MyDAC for RAD
Studio 10.3\Lib\iOSDevice64″;”C:\Program Files (x86)\Steema Software\Steema TeeGrid for VCL & FMX Binary Version
1.09\Compiled\Delphi26.iOSDevice64\Lib”;C:\Users\User\Documents\Webrtc_Delphi_Trial\Bin\IOS;C:\Users\User\Documents\Webrtc_Delphi_Trial\Sources;
C:\Users\User\Documents\Webrtc_Delphi_Trial\Packages\D10\iOSDevice64;C:\Users\User\Documents\Webrtc_Delphi_Trial\Bin\IOS;
C:\Users\User\Documents\Webrtc_Delphi_Trial\Sources;C:\Users\User\Documents\Webrtc_Delphi_Trial\Packages\D10\iOSDevice64;
C:\Users\User\Documents\Webrtc_Delphi_Trial\Bin\IOS;C:\Users\User\Documents\Webrtc_Delphi_Trial\Sources;
C:\Users\User\Documents\Webrtc_Delphi_Trial\Packages\D10\iOSDevice64;D:\techy\delphiComponents\KastriFree-master\include;
D:\techy\delphiComponents\KastriFree-master\API;D:\techy\delphiComponents\KastriFree-master\Core
-LEC:\Users\Public\Documents\Embarcadero\Studio\20.0\Bpl\iOSDevice64 -LNC:\Users\Public\Documents\Embarcadero\Studio\20.0\Dcp\iOSDevice64
-NU.\iOSDevice64\Debug -NSSystem;Xml;Data;Datasnap;Web;Soap; -O..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\FirebaseAnalytics.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\FirebaseCore.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\FirebaseCoreDiagnostics.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\FirebaseInstanceID.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\GoogleAppMeasurement.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\GoogleUtilities.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\nanoPB.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Messaging\FirebaseMessaging.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Messaging\Protobuf.framework;..\..\API;..\..\Core;..\..\Include;..\..\Features\Firebase;
..\..\Features\Notifications;”c:\program files (x86)\embarcadero\studio\20.0\lib\iOSDevice64\Release”;”C:\Program Files (x86)\Devart\MyDAC for RAD
Studio 10.3\Lib\iOSDevice64″;”C:\Program Files (x86)\Steema Software\Steema TeeGrid for VCL & FMX Binary Version
1.09\Compiled\Delphi26.iOSDevice64\Lib”;C:\Users\User\Documents\Webrtc_Delphi_Trial\Bin\IOS;C:\Users\User\Documents\Webrtc_Delphi_Trial\Sources;
C:\Users\User\Documents\Webrtc_Delphi_Trial\Packages\D10\iOSDevice64;C:\Users\User\Documents\Webrtc_Delphi_Trial\Bin\IOS;
C:\Users\User\Documents\Webrtc_Delphi_Trial\Sources;C:\Users\User\Documents\Webrtc_Delphi_Trial\Packages\D10\iOSDevice64;
C:\Users\User\Documents\Webrtc_Delphi_Trial\Bin\IOS;C:\Users\User\Documents\Webrtc_Delphi_Trial\Sources;
C:\Users\User\Documents\Webrtc_Delphi_Trial\Packages\D10\iOSDevice64;D:\techy\delphiComponents\KastriFree-master\include;
D:\techy\delphiComponents\KastriFree-master\API;D:\techy\delphiComponents\KastriFree-master\Core
-R..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\FirebaseAnalytics.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\FirebaseCore.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\FirebaseCoreDiagnostics.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\FirebaseInstanceID.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\GoogleAppMeasurement.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\GoogleUtilities.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\nanoPB.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Messaging\FirebaseMessaging.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Messaging\Protobuf.framework;..\..\API;..\..\Core;..\..\Include;..\..\Features\Firebase;
..\..\Features\Notifications;”c:\program files (x86)\embarcadero\studio\20.0\lib\iOSDevice64\Release”;”C:\Program Files (x86)\Devart\MyDAC for RAD
Studio 10.3\Lib\iOSDevice64″;”C:\Program Files (x86)\Steema Software\Steema TeeGrid for VCL & FMX Binary Version
1.09\Compiled\Delphi26.iOSDevice64\Lib”;C:\Users\User\Documents\Webrtc_Delphi_Trial\Bin\IOS;C:\Users\User\Documents\Webrtc_Delphi_Trial\Sources;
C:\Users\User\Documents\Webrtc_Delphi_Trial\Packages\D10\iOSDevice64;C:\Users\User\Documents\Webrtc_Delphi_Trial\Bin\IOS;
C:\Users\User\Documents\Webrtc_Delphi_Trial\Sources;C:\Users\User\Documents\Webrtc_Delphi_Trial\Packages\D10\iOSDevice64;
C:\Users\User\Documents\Webrtc_Delphi_Trial\Bin\IOS;C:\Users\User\Documents\Webrtc_Delphi_Trial\Sources;
C:\Users\User\Documents\Webrtc_Delphi_Trial\Packages\D10\iOSDevice64;D:\techy\delphiComponents\KastriFree-master\include;
D:\techy\delphiComponents\KastriFree-master\API;D:\techy\delphiComponents\KastriFree-master\Core -U”c:\program files
(x86)\embarcadero\studio\20.0\lib\iOSDevice64\debug”;”C:\Program Files (x86)\Steema Software\Steema TeeGrid for VCL & FMX Binary Version
1.09\Compiled\Delphi26.iOSDevice64\Lib”;..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\FirebaseAnalytics.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\FirebaseCore.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\FirebaseCoreDiagnostics.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\FirebaseInstanceID.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\GoogleAppMeasurement.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\GoogleUtilities.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Analytics\nanoPB.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Messaging\FirebaseMessaging.framework;
..\..\ThirdParty\Firebase\iOS\Firebase.6.2.0\Messaging\Protobuf.framework;..\..\API;..\..\Core;..\..\Include;..\..\Features\Firebase;
..\..\Features\Notifications;”c:\program files (x86)\embarcadero\studio\20.0\lib\iOSDevice64\Release”;”C:\Program Files (x86)\Devart\MyDAC for RAD
Studio 10.3\Lib\iOSDevice64″;”C:\Program Files (x86)\Steema Software\Steema TeeGrid for VCL & FMX Binary Version
1.09\Compiled\Delphi26.iOSDevice64\Lib”;C:\Users\User\Documents\Webrtc_Delphi_Trial\Bin\IOS;C:\Users\User\Documents\Webrtc_Delphi_Trial\Sources;
C:\Users\User\Documents\Webrtc_Delphi_Trial\Packages\D10\iOSDevice64;C:\Users\User\Documents\Webrtc_Delphi_Trial\Bin\IOS;
C:\Users\User\Documents\Webrtc_Delphi_Trial\Sources;C:\Users\User\Documents\Webrtc_Delphi_Trial\Packages\D10\iOSDevice64;
C:\Users\User\Documents\Webrtc_Delphi_Trial\Bin\IOS;C:\Users\User\Documents\Webrtc_Delphi_Trial\Sources;
C:\Users\User\Documents\Webrtc_Delphi_Trial\Packages\D10\iOSDevice64;D:\techy\delphiComponents\KastriFree-master\include;
D:\techy\delphiComponents\KastriFree-master\API;D:\techy\delphiComponents\KastriFree-master\Core
–syslibroot:C:\Users\User\Documents\Embarcadero\Studio\SDKs\iPhoneOS13.4.sdk
–frameworkpath:C:\Users\User\Documents\Embarcadero\Studio\SDKs\iPhoneOS13.4.sdk\System\Library\Frameworks;
C:\Users\User\Documents\Embarcadero\Studio\SDKs\iPhoneOS13.4.sdk\System\Library\PrivateFrameworks;
C:\Users\User\Documents\Embarcadero\Studio\SDKs\iPhoneOS13.4.sdk\System\Library\Frameworks\AbtoSipClientWrapper.embeddedframework -V -VN
–linker-option:”-ObjC -arch arm64″ -NO.\iOSDevice64\Debug EMBTFCMv2Demo.dpr
[DCC Error] E2597 ld: file not found: ImageIO for architecture arm64
[DCC Fatal Error] F2588 Linker error code: 1 ($00000001)
Failed
Elapsed time: 00:00:05.0
Cheers…..
It looks like the macOS SDK did not import correctly. Please follow these steps:
Delete the existing SDK from C:\Users\[username]\Documents\Embarcadero\Studio\SDKs\MacOSX10.15.sdk (or just rename the folder just in case)
Remove the macOS 10.15.x SDK from the SDK Manager in Delphi
Copy C:\Program Files (x86)\Embarcadero\Studio\20.0\bin\MacOSX10.14.defaultsdkpaths to MacOSX10.15.defaultsdkpaths (in the same folder)
Re-add the macOS 10.15.x in the SDK Manager in Delphi
Got it compiled on IOS.
I had to add the following frameworks.
ImageIO
Metal
IOSurface
UserNotifications
As per https://www.tmssoftware.com/site/frameworks.asp
On IOS the app ran I click on Log and get the Token and device ID.
When I use PUSHit
It send but nothing on the IOS device arrives.
{
“to”:”e7k1tihmPnw:APA91bGfKEpM6kCGtCLLSCAG0CiwKkxYWOMaUt03m7oLGMkTWhCtO1l_IQJrOpIG46QxWCpfk1cMfHSycEZ9tfKtY0pXs6P8EFDIG2gWsJegMbGVRgCXx_HDxzccTdtoBjs2GoFs5PYc”,
“notification”:{
“title”:”To IOS”,
“subtitle”:”SUB”,
“body”:”123456″,
“priority”:”normal”
}
}
PUSHIt shows {“multicast_id”:1996509351762761909,”success”:1,”failure”:0,”canonical_ids”:0,”results”:[{“message_id”:”0:1587427992787685%e6375acce6375acc”}]}
Is it an iOS 13.4 device? I’m having trouble with not receiving messages, too. One thing to check though is if the App ID you created for the app on the Apple Developer website has Push Notifications enabled.
ver 13.3.1
I edited the APPID to include Push Notifications.
Did all the certificate stuff.
Change the settings in Delphi.
Got new Token.
Sent message with PushIt but still no message.
I have an older Ipad I’ll try that.
I’m assuming you mean Provisioning Profiles? Does the Bundle Identifier in the Delphi Project Options match the App ID?
Is your project on Firebase Console configured to have an APNs Key?
Ipad Ver 12.4.5
Installed ok.
Got token etc
Message sends but not recived.
I deleted the app on the Firebase and created a new with matching com.xxx.xxx
It confirmed it was working.
Still not receiving.
I have not set anything up on Firebase with ref to APNs.
Just setup tonight to test this.
You will need to, otherwise you will not receive any messages. See here: https://firebase.google.com/docs/cloud-messaging/ios/certs
Followed the procedure in Firebase.
Made changes in Apple Developer
Made changes in Delphi
Installed Xcode certs
Send but no receive on IPAD Or Iphone……
Sorry getting InvalidApnsCredential
I was selecting Notification.
If I select Data it sends but still no reiceve
When sending to iOS, you need to select Notification. If you’re receiving a response with: InvalidApnsCredential, you need to correct the APNs configuration in Firebase Console
I’ll go through the process again.
Tired eyes.
In the Firebase setup do I have to do anything with step 3 or is this handled by your app ?
3
Add Firebase SDK
Instructions for CocoaPods
|
Download ZIPUnityC++
Google services use CocoaPods to install and manage dependencies. Open a terminal window and navigate to the location of the Xcode project for your app.
Create a Podfile if you don’t have one:
content_copy
pod init
Open your Podfile and add:
content_copy
# add the Firebase pod for Google Analytics
pod ‘Firebase/Analytics’
# add pods for any other desired Firebase products
# https://firebase.google.com/docs/ios/setup#available-pods
Save the file and run:
content_copy
pod install
All of what you described is handled by the demo and Kastri Free library code. The demo has paths to the Firebase frameworks that are needed for the app to work, and it would otherwise not receive a token. As per my other comment, it appears you have a problem with APNs configuration because you’re receiving the InvalidApnsCredential response.
Finally Finally.
For anyone else struggling…..
Once you have created your app for iOS in firebase you have to goto the cloud messaging service tab and upload your apple key and enter the key number.
So now working on IOS & Android………..
On iOS I am getting socket error 22 once I switch apps.
Flashing screen every second ????????????
Hi Dave,
A few queries.
1. On the pushIt app only IOS Devices appear in the push devices window.
2. How to add sounds / which folder / type of audio mp3 ? I added bell.mp3 do the resource folder and added sound : bell.mp3 / sound = bell but just got default sound.
3. action_click . Does this mead I can run some code on the device in the background eg ( call a function) If not is this possible ?
4. content_available. The docs state ‘ an inactive client app is awoken’ What’s the meaning of inactive & awoken ?
5. I’m still randomly getting socket error 22 on IOS when opening the app from sleep.
6. Any Delphi related tutorials appreciated .
1. It may be due to an Android permissions issue. I’ll look into resolving this (related to point 5, below)
2. I’d have to look into this
3. Please refer here regarding notification actions: http://docwiki.embarcadero.com/RADStudio/Rio/en/Using_Notifications#Notification_Actions
4. Inactive means “not running”. Awoken means launched into the background, so that any code that handles the message can be executed.
5. This would be due to the UDP mechanism built into the demo. It’s really only used for testing (with PushIt), and the code that creates the PushUDP datamodule can be removed if not testing with PushIt. Regardless, I’ll see if I can resolve the problem
Hi David,
Ive been playing around with notifications.
On IOS the docs state :
content_available Optional, boolean
On iOS, use this field to represent content-available in the APNs payload. When a notification or message is sent and this is set to true, an inactive client app is awoken, and the message is sent through APNs as a silent notification and not through the FCM connection server. Note that silent notifications in APNs are not guaranteed to be delivered, and can depend on factors such as the user turning on Low Power Mode, force quitting the app, etc. On Android, data messages wake the app by default. On Chrome, currently not supported.
https://firebase.google.com/docs/cloud-messaging/http-server-ref
Does this mean if the IOS app is in the background this procedure should happen
procedure TMainView.PushNotificationsMessageReceivedHandler(Sender: TObject; const AJSON: TJSONObject);
begin
LogMemo.Lines.Add(Format(‘Message Received – JSON: %s’, [AJSON.ToString]));
TOSLog.d(‘Message Received – JSON: %s’, [AJSON.ToString]);
end;
What state does inactive refer to ?
Switched app
Pressed home button
App gone to sleep
I am trying to achieve the following with the notification.
Add text to the memo no matter what state IOS or Android is in. Is this possible ?
Hi Dave,
I am trying to implement for iOS the EMBTFCMv2 example in Delphi 10.3.3, sdk 12.1 and XCode 10.2.1. However when the application crashes on startup. I do pass “-ObjC” to the LD linker. Do you have any suggestions?
Hi Dave,
how would I simply send to all the devices ?
ie so firebase would send to any available device
Cheers
Hi Steve,
There’s information on sending to multiple devices, here:
https://firebase.google.com/docs/cloud-messaging/android/send-multiple
There would need to be substantial changes to this implementation (i.e. EMBTFCMv2) to use topics, however topics are already supported in my original implementation:
http://delphiworlds.com/2018/08/firebase-cloud-messaging-revisited/
Device group messaging is something that is managed on the back end (i.e. not in the app itself), and is out of scope for this article, however I am planning to do another article and demo which includes device group messaging in the future.
Hi David,
I managed to use Topics and everything is playing well compiling your app on Android & IOS.
I have added the functionality to an existing IOS app by following all the instructions.
I have used the Identifier I set up to allow pushNotifications etc etc.
The app gives me the Token key for the device. I am using Postman to send a sample message.
{
“to”: “IOS TOKEN”
“notification” : {
“body” : “Congratulations, you received a message”,
“title” : “Firebase Cloud Messaging rules!”,
“badge”: “0”
}
}
And I get a reply:
{
“multicast_id”: 448559026910780824,
“success”: 1,
“failure”: 0,
“canonical_ids”: 0,
“results”: [
{
“message_id”: “0:1590449359582063%304233dc304233dc”
}
]
}
But no notification on the device.
Any ideas on which part of the jigsaw I might be missing ?
I’m having the same issue on occasions, and I’m having trouble working out exactly what the problem is. What version of iOS is on your device?
iOS 13.5 on iPhone and 12.4.7 on an iPad.
I’m still receiving notifications via your app EMBTFCMV2DEMO
Which one are you having problems with?
EMBTFCMV2 runs fine on both IOS devices and Android. It doesn’t miss any messages.
I have added your code to an existing app(testPhone) and on both IOS devices I receive the token but cannot send.
I’ve just compiled TestPhone on Android and that creates a Token and receives messages.
So I think I’m missing a little piece of the jig saw when adding all the bits to my TestPhone ?????
Sorry I receive the token but cannot send from Postman.
By “cannot send” do you mean the send fails, or the device does not receive the message? Does it receive the message when in the foreground?
Sorry late & tired……
From Postman I use :
{
“to”: “IOS TOKEN”
“notification” : {
“body” : “Congratulations, you received a message”,
“title” : “Firebase Cloud Messaging rules!”,
“badge”: “0”
}
}
And I get a reply:
{
“multicast_id”: 448559026910780824,
“success”: 1,
“failure”: 0,
“canonical_ids”: 0,
“results”: [
{
“message_id”: “0:1590449359582063%304233dc304233dc”
}
]
}
If I use the tokens provided by your app EMBTFCMV2. Works okay on the 2 IOS Devices & Android.
On my testPhone app using the above from Postman I get the success : 1 sending to all 3 devices.
No message arrives on IOS devices.
Messages arrive on the Android.
We worked out the inconsistencies were because I was using the same certs for 2 different apps.
Hi David,
I have some code on PushNotificationsMessageReceivedHandler which parses the message.
If the app has focus the message is processed if the app is in the background and I press the notification I am not getting all the message on the notification click.
In Foreground.
Message Received – JSON: {“google.delivered_priority”:”high”,”gcm.notification.payload”:”{\”outGoing\”:\”1004\”,\”domain\”:\”\\\/topics\\\/test.domain.com\”,\”callerID\”:\”JohnDad\”,\”direction\”:\”inbound\”}”,”google.sent_time”:”1590612592578″,”google.ttl”:”2419200″,”google.original_priority”:”high”,”gcm.notification.e”:”1″,”gcm.notification.title”:”JohnDad Is Calling Number 1004″,”from”:”\/topics\/test.domain.com”,”google.message_id”:”0:1590612593098051%e6375acce6375acc”,”gcm.notification.body”:”IDirection is inbound”,”google.c.a.e”:”1″,”google.c.sender.id”:”400149148812″,”gcm.notification.tag”:”topic_key_6324997883835317324″,”collapse_key”:”com.delphiworlds.test”}
In Background.
Message Received – JSON: {“google.delivered_priority”:”high”,”google.sent_time”:”1590612617556″,”google.ttl”:”2419200″,”google.original_priority”:”high”,”from”:”\/topics\/test.domaain.com”,”google.message_id”:”0:1590612618071346%e6375acce6375acc”,”collapse_key”:”com.delphiworlds.test”}
What am I doing wrong here please ?
Please, someone who managed to push Firebase could make their classes available to help us. I for example couldn’t register my app on Firebase how would I do that?
Hi Rodolfo,
Do you mean that you’re unable to receive a Firebase token? Have you completed all the configuration for your project in Firebase Console?:
https://console.firebase.google.com/