This is Part 2 of a 2-part article on incorporating support for FCM in your Delphi apps for Android and iOS, and this part covers implementation on iOS.
Issues with later versions of the Firebase SDK: For those who are having compile issues with later versions of the SDK, I’m working on resolving the problems. Meanwhile, earlier versions of the the SDK may be downloaded using a URL in this format:
https://dl.google.com/firebase/sdk/ios/x_y_z/Firebase-x.y.z.zip
Where x, y, and z relate to the version number, so for version 4.3.0 the URL is:
https://dl.google.com/firebase/sdk/ios/4_3_0/Firebase-4.3.0.zip
FireDAC SQLite issue: Thanks to Steven Chesser who found this issue, and to Dmitry Arefiev for coming up with a solution:
If you’re using FireDAC with SQLite in your app, you’ll likely find that the app crashes on startup. It appears that FireDAC binds to SQLite static libraries that are incompatible with FCM. To alleviate this issue, please follow these steps:
- Make a copy of FireDAC.inc from the C:\Program Files (x86)\Embarcadero\Studio\xx.0\source\data\FireDAC folder, and put it in your project folder (where xx is the number for your Delphi install e.g. 18 for Delphi 10.1 Berlin)
- Modify FireDAC.inc to change the line:
{.$UNDEF FireDAC_SQLITE_STATIC}
Remove the “.” after the “{” so that it becomes:
{$UNDEF FireDAC_SQLITE_STATIC} - In Project Options, select: All configurations – iOS Device- 64 bit platform, and add the following to the search path:
$(BDS)\source\data\FireDAC - Clean and Build the project (as opposed to Compile), run it, and all should be OK
If you haven’t done so already, please read at least step 1 of Part 1, because it has important information about how to retrieve the .plist file that’s required for your iOS app, and about the starter project.
This article assumes that you have a certificate, app id and provisioning profile set up already, and added to your Mac. If you do not, please refer to this article.
Let’s start!
1. Download the Firebase SDK from the Firebase site
Go to the Firebase iOS setup page, navigate to the “Integrate Without Cocoa Pods” section (since we’re not using Cocoa Pods) and click the link in step 1 to download the SDK. Extract it somewhere appropriate that’s common to your applications. Inside, you’ll notice a a bunch of folders, and inside each folder is one or more “framework” folders (they have an extension of “.framework”). Inside each of those, in the root, is a file with the same name, with no extension. These are the binaries that your app needs in order to use the Firebase SDK.
2. Add paths to the framework files in your Delphi project
The easiest way to make it so that the compiler can find the files is to add a path for each of the necessary frameworks. In the Project Options for your Delphi project, select Delphi Compiler in the tree, and select All configurations – iOS Device – 64 bit platform in the Target combo box. In the Search Path option, you’ll need to add a path for each of the following (where <firebase> is the root of the Firebase SDK that you extracted):
<firebase>\AdMob\GoogleMobileAds.framework\
<firebase>\Analytics\FirebaseAnalytics.framework\
<firebase>\Analytics\FirebaseCore.framework\
<firebase>\Analytics\FirebaseInstanceID.framework\
<firebase>\Analytics\FirebaseNanoPB.framework\
<firebase>\Analytics\GoogleToolboxForMac.framework\
<firebase>\Analytics\nanoPB.framework\
<firebase>\Messaging\FirebaseMessaging.framework\
<firebase>\Messaging\Protobuf.framework\
<firebase>\RemoteConfig\FirebaseRemoteConfig.framework\
While we’re in the Project Options, you’ll also need to add a parameter to the Linker options. Under Delphi Compiler, select Linking, and add -ObjC to the “Options passed to the LD linker” option (as per part 3 of the SDK requirements for apps not using Cocoa Pods on the Firebase iOS setup page):
You’ll need to repeat the above for iOS Device – 32 bit platform when you’re ready to deploy to the App Store or Test Flight, unless Apple has removed the 32-bit requirement by then.
Go to the Version Info section of the Project Options and modify the CFBundleIdentifier field so that it matches the identifier for your App ID on the Apple Developer site:
Then go to the Provisioning section, just to make sure the certificate and provisioning profiles have been found, and click OK.
3. Add the required frameworks from the iOS SDK to the Delphi SDK Manager
If you’re not already familiar with how to add other frameworks to the iOS SDK, you can refer to this article. You’ll need to add each of the following frameworks:
AdSupport
AudioToolbox
AVKit
CoreAudio
CoreMIDI
MediaToolbox
Metal
SystemConfiguration
UserNotifications
Note that the case of the name is very important! (eg it’s CoreMIDI, not CoreMidi). Remember to click Update Local File Cache when you are done adding those, and remember to click OK.
4. Add GoogleService-info.plist to the deployment
In Delphi, click Project, Deployment and select All configurations – iOS Device – 64 bit platform in the combo. Click the button with the white rectangle and green “+” on it to add, then select your GoogleService-info.plist file and click Open, e.g:
Now: would you believe that is it? Other than compiling and running your project, that is. While Monitor is good for watching log messages on Android, on iOS I find iOSConsole to be a decent equivalent on iOS, and it doesn’t require you to start Xcode. If you download that (onto your Mac), install and run it, you’ll be able to see the log messages for the starter project. Put the text “FCMStarter” (without the quotes) in the filter box of iOSConsole.
Run the app, and the first time you do, you’ll be prompted as to whether you would like the app to receive notifications. Be sure to tap “Allow”! You should also see the token appear in the upper memo. The token will also appear in the iOSConsole window:
Just like in Android’s Monitor app, you can copy the lines in iOSConsole, and extract the token from the copied text.
For iOS, FCM messages need to be of the notification format, e.g:
[sourcecode language=”javascript”]
{
"to": "(yourtoken)"
"notification" : {
"body" : "Congratulations, you received a message",
"title" : "Firebase Cloud Messaging rules!",
"badge": "0"
}
}[/sourcecode]
Where (yourtoken) is the one you retrieved from the log.
Please refer to the last step of the previous article where I mention how to use Hurl to send test messages. If you’re using the starter project, you should check that notifications appear in the memo on the main form when the app is running, and for all apps using this framework, notifications will appear in the notification center when the app is in the background, or not running at all.
That’s all on this subject for the moment. There may be follow-up articles as to how to go about using the SubscribeToTopic and UnsubscribeFromTopic methods, and further developments going forward.
Hi. What are the differences in the settings if the project is for С++ Builder? Thanks.
I don’t use C++Builder, so I’m unaware of what the differences might be. Are you having a particular issue?
Hello Dave!
Congratulations for this post. I’ve been waiting a long time for this solution. Thank you very mutch!
I have no issue on Android deployment, its everything ok.
For IOS, I downloaded Firebase SDK exactly is specified in step 1 (Firebase iOS setup page-Integrate Without Cocoa Pods). After unzip it, I realized that folder “\Messaging\Protobuf.framework\” and it framework doesn’t exist. So, do you have, please, another url to download the same version of Firebase SDK you used in this project?
I got a second error message too: “[DCC Error] E2597 ld: framework not found AdSupport for architecture arm64”, I don’t know if this one is related to the Firebase SDK version
Your help is appreciated
Best regards,
Marco
Hi Marco,
It looks like I’m going to need to update the code and the article, as there doesn’t appear to be a way of downloading earlier versions of the SDK, and it’s probably a good idea to update it anyway.
Stay tuned
I’ve now updated the article, and one of the units to support Firebase SDK 4 (and above)
Hello Dave,
First of all, congratulations on the great work!
After following all the steps and trying to compile, I get the same error message as Marco: ld: framework not found AdSupport for architecture arm64
I can’t find the error. Any help is very much appreciated.
Thank you!
Hello Dave,
Thank you for this great piece of work!
At first I had some trouble to get it running, but now I can receive remote notifications from Firebase perfectly!
Here’s what I had to do:
1. Add frameworks “AdSupport” and “AVKit”, and Update Local File Cache
2. Edit DW.iOSapi.Firebase, add “procedure setDelegate(delegate: Pointer); cdecl;” on line 126. It seems that setRemoteMessageDelegate is deprecated and causes a crash if used.
3. Edit DW.Firebase.Messaging.iOS, commenting line 179 (“TFIRMessaging.Wrap(TFIRMessaging.OCClass.messaging).setRemoteMessageDelegate(FFIRMessagingDelegate.GetObjectID);”)
4. Edit DW.Firebase.Messaging.iOS, adding line “TFIRMessaging.Wrap(TFIRMessaging.OCClass.messaging).setDelegate(FFIRMessagingDelegate.GetObjectID);”
After that, remote notifications are received.
Thank you very much and keep up the great work!
Hello Dave.
Thank you for useful post.
I am using android version very well.
and now I’m trying to apply Ios version.
After following all the steps and trying to compile, I get the error message “[DCC Error] E2597 Undefined symbols for architecture arm64”.
When I add-ObjC in Linking – Options passed to the LDlinker, I get the error message.
Any help is very much appreciated.
Thank you
Please check step 2. Have you added the path for \Analytics\FirebaseNanoPB.framework\ to the project compiler path? If so, please post the details of the error: there should be a “+” symbol that you can expand that will show what symbols the compiler could not find.
I added all path in step 2.
– I added these path to the Project Options – Delphi Compliler – Search path
: D:\Component\Firebase\AdMob\GoogleMobileAds.framework\;
D:\Component\Firebase\Analytics\FirebaseCore.framework\;
D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\;
D:\Component\Firebase\Analytics\FirebaseInstanceID.framework\;
D:\Component\Firebase\Analytics\GoogleToolboxForMac.framework\;
D:\Component\Firebase\Messaging\FirebaseMessaging.framework\;
D:\Component\Firebase\Analytics\FirebaseNanoPB.framework;
D:\Component\Firebase\RemoteConfig\FirebaseRemoteConfig.framework\;
D:\Component\Firebase\Messaging\Protobuf.framework
and I got these error message
:
Error: “_pb_encode_string”, referenced from: _nano_encode_string in D:\Component\Firebase\Analytics\FirebaseNanoPB.framework\FirebaseNanoPB(encoder_common_8039ece0c83ac7b8d23f0821feb0bc6b.o);
Error: “_pb_read”, referenced from: _firapb_decode_repeated_audience in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_audience_decoder_8f2b7f20b40a4bf280eef0193d412fed.o); _firapb_decode_repeated_audience_leaf_filter_result in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_audience_leaf_filter_result_decoder_18719ebed44aede4ae1b5366ad8ab378.o); _firapb_decode_repeated_event in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_decoder_b12f86d34ef07b7785c71e30f0f2bdec.o); _firapb_decode_repeated_event_config in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_config_decoder_cde32d44905cc0603c340053f5acc2cc.o); _firapb_decode_repeated_event_filter in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_filter_decoder_ec6b4dfae7767911eff6ccffc13f7296.o); _firapb_decode_repeated_event_param in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_param_decoder_44c77717d048228f22bd72a81dca7cf5.o); _firapb_decode_repeated_filter in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_filter_decoder_8f86ab1b6526e1718ca4d06d5548ff97.o); …
Error: “_pb_decode”, referenced from: _firapb_decode_audience in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_audience_decoder_8f2b7f20b40a4bf280eef0193d412fed.o); _firapb_decode_audience_leaf_filter_result in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_audience_leaf_filter_result_decoder_18719ebed44aede4ae1b5366ad8ab378.o); _firapb_decode_event in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_decoder_b12f86d34ef07b7785c71e30f0f2bdec.o); _firapb_decode_event_config in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_config_decoder_cde32d44905cc0603c340053f5acc2cc.o); _firapb_decode_event_filter in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_filter_decoder_ec6b4dfae7767911eff6ccffc13f7296.o); _firapb_decode_event_param in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_param_decoder_44c77717d048228f22bd72a81dca7cf5.o); _firapb_decode_filter in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_filter_decoder_8f86ab1b6526e1718ca4d06d5548ff97.o); …
Error: “_pb_istream_from_buffer”, referenced from: _firapb_decode_audience in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_audience_decoder_8f2b7f20b40a4bf280eef0193d412fed.o); _firapb_decode_audience_leaf_filter_result in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_audience_leaf_filter_result_decoder_18719ebed44aede4ae1b5366ad8ab378.o); _firapb_decode_event in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_decoder_b12f86d34ef07b7785c71e30f0f2bdec.o); _firapb_decode_event_config in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_config_decoder_cde32d44905cc0603c340053f5acc2cc.o); _firapb_decode_event_filter in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_filter_decoder_ec6b4dfae7767911eff6ccffc13f7296.o); _firapb_decode_event_param in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_param_decoder_44c77717d048228f22bd72a81dca7cf5.o); _firapb_decode_filter in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_filter_decoder_8f86ab1b6526e1718ca4d06d5548ff97.o); …
Error: “_pb_encode_submessage”, referenced from: _firapb_encode_repeated_audience in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_audience_encoder_72c4ae8dbc6687ec3f3995499df06f95.o); _firapb_encode_repeated_audience_leaf_filter_result in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_audience_leaf_filter_result_encoder_6cbefb9d90fdddfe6d231875ed5b6a81.o); _firapb_encode_repeated_event in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_encoder_0c153acc04fdbe51594c94848d0368b0.o); _firapb_encode_repeated_event_config in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_config_encoder_b76c27c645bff35f43c88abf3308a055.o); _firapb_encode_repeated_event_filter in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_filter_encoder_622d09830d24d1c5bf26be1b23f22eb3.o); _firapb_encode_repeated_event_param in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_param_encoder_fb98584a84d6fa363809bc8f957886cc.o); _firapb_encode_repeated_filter in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_filter_encoder_d28bfc4dffa3c4e05d93004539cd7c73.o); …
Error: “_pb_encode_tag_for_field”, referenced from: _firapb_encode_repeated_audience in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_audience_encoder_72c4ae8dbc6687ec3f3995499df06f95.o); _firapb_encode_repeated_audience_leaf_filter_result in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_audience_leaf_filter_result_encoder_6cbefb9d90fdddfe6d231875ed5b6a81.o); _firapb_encode_repeated_event in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_encoder_0c153acc04fdbe51594c94848d0368b0.o); _firapb_encode_repeated_event_config in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_config_encoder_b76c27c645bff35f43c88abf3308a055.o); _firapb_encode_repeated_event_filter in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_filter_encoder_622d09830d24d1c5bf26be1b23f22eb3.o); _firapb_encode_repeated_event_param in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_event_param_encoder_fb98584a84d6fa363809bc8f957886cc.o); _firapb_encode_repeated_filter in D:\Component\Firebase\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(firapb_filter_encoder_d28bfc4dffa3c4e05d93004539cd7c73.o); …
Error: “_pb_decode_varint”, referenced from: _nano_decode_repeated_uint64 in D:\Component\Firebase\Analytics\FirebaseNanoPB.framework\FirebaseNanoPB(decoder_common_c0739af9e66f99653329d62a5a0fe57b.o);
Error: “_pb_encode_varint”, referenced from: _nano_encode_repeated_uint64 in D:\Component\Firebase\Analytics\FirebaseNanoPB.framework\FirebaseNanoPB(encoder_common_8039ece0c83ac7b8d23f0821feb0bc6b.o);
Error: “_pb_encode”, referenced from: _nano_two_pass_encoding in D:\Component\Firebase\Analytics\FirebaseNanoPB.framework\FirebaseNanoPB(encoder_common_8039ece0c83ac7b8d23f0821feb0bc6b.o);
Error: “_pb_ostream_from_buffer”, referenced from: _nano_two_pass_encoding in D:\Component\Firebase\Analytics\FirebaseNanoPB.framework\FirebaseNanoPB(encoder_common_8039ece0c83ac7b8d23f0821feb0bc6b.o);
ld: symbol(s) not found for architecture arm64
Thank you.
I’m having a similar problem with the latest version of the Firebase SDK (4.1.0), it compiles OK with version 4.0.2.
I’ll take a look into what the problem is.
Oh, I only could download SDK(4.1.0) in https://firebase.google.com/docs/ios/setup.
Can I get the url for SDK(4.0.2) download?
I think I have found the issue. Firebase SDK version 4.1.0 relies on another framework, namely nanoPB. Please add the following path to the compiler path in project options:
[Firebase]\Analytics\nanoPB.framework
Where [Firebase] is your Firebase SDK folder. Also, please update this file:
https://github.com/DelphiWorlds/KastriFree/blob/master/API/DW.iOSapi.Firebase.pas
That should have it compiling without errors. Note that I am yet to test this, which I will do in a few hours if no-one else has by then.
I ‘ve tested with modified DW.iOSapi.Firebase.pas.
It works very well!! Thank you so much.
and I have another questions.
In android, I modified jar file to use sqlite when received notification at running background.
I want to use sqlite when received notification at running background.
Can I customize it like android in ios fcm service ?
Hi Dave.
When app is in foreground, it could receive push message. but no alert, sound..
And app is in background, it’s not response when send message.
I registered APN certifications in Firebase console.
If it received in background, should I do something additional?
Thank you.
Are you sending the message via the Firebase Console? If so, they will not work properly in iOS. Use HURL, as I’ve described in the articles.
Yes I used Hurl. But It works only in foreground..
Are you sending “notification” messages as per the iOS article? Data messages will not work on iOS
I sended “notification” message via Hurl. But It only works in foreground.
My App is developer version, so I’ll check registered certification IDs at Apple developer web again.
And, Could you answer it to this question?
//
In android, I modified jar file to use sqlite when received notification at running background.
I want to use sqlite when received notification at running background.
Can I customize it like android in ios fcm service ?
//
Thank you so much for help.
I don’t know why it wouldn’t be working in the background; it should.
As far as the SQLite question goes: there’s no such thing as a “service” in iOS. You might be able to access a SQLite database when the notification is received when the app is running in the background. I may have a look at this myself later.
Thank you!!
Now It works very well in background.
I think certification settings was configured incorrectly.
I’m looking forward to answering about to access a SQLite database in background.
Thank you.
[DCC Error] DW.Firebase.Messaging.iOS.pas(110): E2003 Undeclared identifier: ‘NSDictionaryToJSON’
My apologies. I did some re-arrangement of the code which broke it. Can you update your copy of this unit, please?
https://github.com/DelphiWorlds/KastriFree/blob/master/Core/DW.iOSapi.Helpers.pas
Everything is perfect but a crash happens when the application asks for notification permission at the first startup. When I checked, FMessaging := TFirebaseMessaging.Create; this line causes the problem. Why do you think does this happen? PS: I removed all firedac units.
paserver error message: Error: Command Args. Validation failed. Mandatory args not found: name
project … “raised exception class 6”
Can you provide a call stack of when the app crashes, please? When the crash occurs and the debugger stops, click the Break button and it should a window with the call stack
https://i.hizliresim.com/WG6NOm.png
https://i.hizliresim.com/3p1m40.png
I need to be able to see the complete call stack. The 2nd image you’ve provided only has a small portion of it (in the top left, where it says “Call Stack”).
Some other things to check for: Please ensure you’re creating one (and only one) instance of TFirebaseInstanceId, *before* you create an instance of TFirebaseMessaging and attempt to use it.
https://i.hizliresim.com/YOjnvz.png
Unfortunately the complete call stack is not of any help. Have you checked the other concerns I mentioned? Does the original starter project work for you?
I tried all but unfortunately none of them worked. Many thanks for your help.
delphi tokyo?
it worked out like this
procedure TPlatformFirebaseMessaging.RegisterRemoteNotificationsIOS10OrLater(const AOptions: UNAuthorizationOptions);
begin
FUserNotificationCenterDelegate := TUserNotificationCenterDelegate.Create(self);
TUNUserNotificationCenter.OCClass.currentNotificationCenter.setdelegate(FUserNotificationCenterDelegate.GetObjectID);
UserNotificationCenter.requestAuthorizationWithOptions(AOptions, RequestAuthorizationWithOptionsCompletionHandler);
FFIRMessagingDelegate := TFIRMessagingDelegate.Create(self);
// TFIRMessaging.Wrap(TFIRMessaging.OCClass.messaging).setDelegate(FFIRMessagingDelegate.GetObjectID);
TiOSHelper.SharedApplication.registerForRemoteNotifications;
end;
Hello Dave.
Have you looked at that access a SQLite database when app is running in the background?
If not, could you tell me way to do this?
I am also looking into it, but I have no idea how to approach.
I need to do this as soon as possible because of work..
Any help is very appreciated.
Thank you.
Could you describe exactly the problem you’re having? Is it on iOS?
Yes, It’s on iOS.
In android, I modified Java file and remake jar file to access a SQLite database when received notifications app is in the background.
Now I need to do this in iOS.
What should I modify, how to approach .. I don’t know.
Hello Dave.
Congratulations on your article.
I have a problem with FCMStarter on iOS: it works fine when the application is open, but closed or in the background it receives the message but the notification banner does not appear.
Do you have any idea what that might be? Is it anyway or should I get a notification? That’s what I need to do: notify the person that a new message has arrived.
Thanks a lot for the help.
I’ve had a few enquiries about this scenario. Usually, it’s due to the type of message being sent. Messages sent from the Firebase console don’t turn up when the app is not running or in the background because iOS does not support those types in those scenarios (they’re called “Data” messages). I’ll revisit this to make doubly sure, and check whether something else is going on. See also Veli’s comment regarding the change they made to the code; I’m yet to check this.
Dave,
Thanks for the answer.
I wrote a server to send a message.
He uses the url: “https://fcm.googleapis.com/fcm/send”
and the test message I send to my iPhone device is:
{
“to”: “d9cse7iMDxgAPA9 …”,
“priority”: “high”,
“content_available”: true,
“notification”: {
“body”: “New Message”,
“title”: “Test”,
“icon”: “FCMStarter”,
“badge”: “2”
}
}
And I receive in response:
{
“multicast_id”: 54042740 …,
“success”: 1,
“failure”: 0,
“canonical_ids”: 0,
“results”: [{“message_id”: “0: 15063745 ….”}}
}
With the FCMStarter app open, everything works,fine, but with the app closed nothing happens.
When I open the app, then the message appears.
Remote notification does not depend on the app, right? Because it is closed when the device receives the notification. They should appear without any interference from the app.
On android works fine, but on iOS I have not got it yet.
Any help, I thank you very much.
Thank you,
Ricardo
Thanks for the additional info. I will look into this later today
paserver error sending delphi tokyo with ipa
[PAClient Error] Error: E0776 error: exportArchive: “EkolKBB.app” requires a provisioning profile with the Push Notifications feature.
You are either using Xcode 9 without the recent patch:
https://cc.embarcadero.com/Item/30805
or the provisioning profile you are using does not include push notifications, which is mentioned before step 1 and refers to this link:
https://quickblox.com/developers/How_to_create_APNS_certificates
Hello. I am stuck with the follow error.
MSBUILD : error E2597: E2597 ld: framework not found AdSupport for architecture arm64
e:\dev\rad\10.2\embarcadero\studio\19.0\Bin\CodeGear.Delphi.Targets(399,5): error F2588: F2588 Linker error code: 1 ($00000001)
Please help.
And this is the line before
C:\Users\Mars\Desktop\delphi Push Firebase\DW.iOSapi.Helpers.pas(36,4): warning H2443: H2443 Inline function ‘NSObjectToID’ has not been expanded because unit ‘Macapi.ObjectiveC’ is not specified in USES list
fixed.
Hi, Dave.
I have done everything as described in article, but I am getting the following error:
[DCC Error] E2597 Undefined symbols for architecture arm64:
Error: “_SCNetworkReachabilityUnscheduleFromRunLoop”, referenced from: _kFIRDefaultReachabilityApi in Z:\3rdParty\Firebase\IOS\Analytics\FirebaseCore.framework\FirebaseCore(FIRReachabilityChecker_00b225aa897c9828a14d2955cb3db962.o);
Error: “_OBJC_CLASS_$_SKProductsRequest”, referenced from: objc-class-ref in Z:\3rdParty\Firebase\IOS\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(FIRAProductsRequest_8f770071350872416d311668917f3a41.o);
Error: “_SCNetworkReachabilityCreateWithName”, referenced from: _kFIRDefaultReachabilityApi in Z:\3rdParty\Firebase\IOS\Analytics\FirebaseCore.framework\FirebaseCore(FIRReachabilityChecker_00b225aa897c9828a14d2955cb3db962.o);
Error: “_OBJC_CLASS_$_SKPaymentQueue”, referenced from: objc-class-ref in Z:\3rdParty\Firebase\IOS\Analytics\FirebaseAnalytics.framework\FirebaseAnalytics(FIRAnalytics_20f381a67e6d70f1b973db7e9586fcd2.o);
Error: “_SCNetworkReachabilityScheduleWithRunLoop”, referenced from: _kFIRDefaultReachabilityApi in Z:\3rdParty\Firebase\IOS\Analytics\FirebaseCore.framework\FirebaseCore(FIRReachabilityChecker_00b225aa897c9828a14d2955cb3db962.o);
Error: “_SCNetworkReachabilitySetCallback”, referenced from: _kFIRDefaultReachabilityApi in Z:\3rdParty\Firebase\IOS\Analytics\FirebaseCore.framework\FirebaseCore(FIRReachabilityChecker_00b225aa897c9828a14d2955cb3db962.o);
ld: symbol(s) not found for architecture arm64
I do have SystemConfiguration framework referencerd in SDK manager so I don’t understand why it complains.
Do you have any idea how to resolve this?
Thanks in advance,
Mujislav
It may be that you did not click “Update Local File Cache” in the SDK manager after adding the frameworks.
I have deleted local cache by hand and then update it again. Now it works. Go figure.
Thanks!
I rejoiced too early. I still get the same error message 🙁
Dave,
could you please tell me what version of Firebase IOS SDK are you using?
When I try the latest version of SDK (4.8.2) with latest version of KastriFree I get the above mentioned error.
I’m using 4.3.0. I know there’s issues with later versions; it’s something I’ve been meaning to address. You should be able to download 4.3.0 from here: https://dl.google.com/firebase/sdk/ios/4_3_0/Firebase-4.3.0.zip. The URL for other versions follows the same pattern
I did. That is why I am confused
Hello, Dave.
Firstly congratulations for the article. It was a great help!
I’m having problem only on ios. When the application boots it crashes.
“Raised exception class 6”
I made the modifications to Firedac.ini and Veli’s suggestions. Do you have any tips on what it might be?
Below the link to call stack
http://www.fcleal.com.br/img/stack/img1.png
http://www.fcleal.com.br/img/stack/img2.png
http://www.fcleal.com.br/img/stack/img3.png
http://www.fcleal.com.br/img/stack/img4.png
http://www.fcleal.com.br/img/stack/img5.png
Thank you very much.
Hello Dave,
I was able to solve the problem of crashes on startup.
My library “Kastri” was outdated. Now the app initializes normally, but I do not get the token. Do you know what it can be?
Hi Fernando,
I suggest using iOSConsole: http://lemonjar.com/iosconsole/
To view the messages for your app. When you run iOSConsole, in the top left there’s a Filter edit box – type in the name of your app to see the messages for your app. If there’s an issue with FCM, you should see messages related to it.
Hi Dave!
Thanks for the feedback.
The only thing I found on iOSConsole was this line
“4/13/18, 8:42:07 PM SpringBoard (UserNotificationsServer) [56]: [com.keepin.keepin] Enable notifications: 0 [authorizationOptions: 7]”
Is that the problem?
Nothing with FCM appears.
Thank you
No, that message is normal. You should at least see a line like this:
14/4/18, 9:26:29 am PushTest[441]: 4.11.0 – [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you’d prefer to manually integrate Firebase Messaging, add “FirebaseAppDelegateProxyEnabled” to your Info.plist, and set it to NO. Follow the instructions at:
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.
In my case, the app name is PushTest. Are you using the starter project code? If not, perhaps your code is not calling the Start method, either on the TFirebaseInstanceId instance or the TFirebaseMessaging instance.
Dave, thank you so much for the help.
I put it in app oncreation
FInstanceId.Start;
FInstanceId.Token;
And now I’m getting the token.
Thank you!
Hello, Dave. First of all thank you for the very detailed article. Your test project runs ok, I receive the token and can sen notifications via Firebase. But when I try to run the same code, integrated in our app, it crashes. I’ve added all the frameworks and strictly did everything that you described here. Actually I checked the project options of your test application and I put all the same settings in my application in order to run it. Unfortunately when I follow the logs I see that my app crashes on “function TPlatformFirebaseMessaging.Messaging: FIRMessaging;
begin
Result := TFIRMessaging.Wrap(TFIRMessaging.OCClass.messaging);
end;” in DW.Firebase.Messaging.iOS and more specifically on the “messaging” function in DW.iOSapi.Firebase. I am using Delphi Rio 3.1, but as I said I have no problems with your test project so far. Do you have any idea what am I doing wrong with my application and what should I check for? Thank you in advance !
Hi Alex,
Can you provide the exact error message(s), if any? Please make sure the Project Options are the same, particularly the -ObjC flag in the linker options
Hi Dave! I started to get the error below when the application initializes. It starts to initialize and closes.
In IOSConsole I get the following message
ReportCrash (CoreServices) [687]: notify_register_check () failed with error 1000000
Does it have any relationship with FCM?
best regards
Hi Fernando,
Not sure what might be causing that. Are you using the FCMRevisited project?
https://github.com/DelphiWorlds/KastriFree/tree/master/Demos/FCMRevisited
Which is the one you should be using, and mentioned in this article:
http://delphiworlds.com/2018/08/firebase-cloud-messaging-revisited
Cheers,
Dave
hi Dave
I wrote a server to send a message.
He uses the url: “https://fcm.googleapis.com/fcm/send”
and the test message I send to my iPhone device is:
{
“to”: “d4q0FPvvkFg……”,
“notification” : {
“body” : “Congratulations, you received a message”,
“title” : “Firebase Cloud Messaging rules!”,
“badge”: “0”
}
}
And I receive in response:
{
“multicast_id”: 8058076877386421666,
“success”: 1,
“failure”: 0,
“canonical_ids”: 0,
“results”: [
{
“message_id”: “1588520685117865”
}
]
}
the notification does not come to the phone
On android works fine, but on iOS I have not got it yet.
thank
What version of iOS is on your device? I’ve been having the same trouble with my device which is iOS 13.4