iOS Tutorial FirebaseNotifications / Push Messages (server not required)

Not open for further replies.

Firebase Notifications service makes it relatively easy to send push messages.

Integrating Firebase:

Push messages in iOS requires some configuration.

1. Create a new explicit (non-wildcard) App ID with the package name of the push app. For example anywheresoftware.b4i.push. Enable push notification service.
2. Create an Apple Push Notification SSL certificate. Use the same certSigningRequest.csr file that you previously created.
This can be done from App IDs - Choose the id - Edit.

I recommend using a Production SSL Certificate with a Distribution / Ad Hoc provision profile. This way you can use the same tokens during development and in production.

3. Create a provision file with the new App ID.

Update: It is simpler to use the new and recommended APN authentication keys:

Old keys (works as well):
4. There should be a file named aps_*.cer in the keys folder. Now you should click on Tools - Build Server - Create Push Key - Firebase Service:


This will create a file named firebase_push.p12 in the keys folder. You need to upload it to Firebase console under Settings - CLOUD MESSAGING:


You only need to upload the production APN.

5. Download GoogleService-Info.plist and copy it to Files\Special folder.


The code should be similar to:
#Entitlement: <key>aps-environment</key><string>production</string>
'use the distribution certificate
#CertificateFile: ios_distribution.cer
'use the provision profile that goes with the explicit App Id
#ProvisionFile: Firebase.mobileprovision
Sub Process_Globals
   Public App As Application
   Public NavControl As NavigationController
   Private Page1 As Page
   Private analytics As FirebaseAnalytics
   Private fm As FirebaseMessaging
End Sub

Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Title = "Page 1"
   Page1.RootPanel.Color = Colors.White
   App.RegisterUserNotifications(True, True, True)
End Sub

Private Sub fm_FCMConnected
   'here we can subscribe and unsubscribe from topics
   fm.SubscribeToTopic("ios_general") 'add ios_ prefix to all topics
End Sub

Private Sub Application_RemoteNotification (Message As Map, CompletionHandler As CompletionHandler)
   Log($"Message arrived: ${Message}"$)
   Msgbox(Message, "Push message!")
End Sub

Private Sub Application_Active
   fm.FCMConnect 'should be called from Application_Active
End Sub

Private Sub Application_Background
   fm.FCMDisconnect 'should be called from Application_Background
End Sub

Sub Application_PushToken (Success As Boolean, Token() As Byte)
   Log($"PushToken: ${Success}"$)
End Sub

Use the attached B4J (non-ui) program to send messages. It handles ios messages a bit differently. There is an assumption that all iOS topics start with ios_.


    1 KB · Views: 1,902
Last edited:


Active Member
Licensed User
Longtime User
Yes. What happens when you run it? Do you see the push token logs?

In the fcm_connected is subscribe to ios+general, I am getting a PushToken:1 from the log and a token is being generated. If I send from firebase it shows as completed, but no devices.

My b4j app log is this :

Waiting for debugger to connect...
Program started.
[jobname=fcm, success=true, username=
, password=, errormessage=, target=class b4j.example.main
, taskid=1, req=anywheresoftware.b4h.okhttp.OkHttpClientWrapper$OkHttpRequest@133314b, tag=java.lang.Object@b1bc7ed
, httputils2service=null]

Thanks in advance.


Active Member
Licensed User
Longtime User
You mean ios_general, right?

This is not relevant. Don't use Firebase console.

The message was sent successfully.
Are you using the exact code from the tutorial?

Have you tested it in both background and foreground modes?

Ok, thanks. I have checked the code but will do so again. I have tried foreground and background. I will keep checking, thanks for your input, it is appreciated.



Active Member
Licensed User
Longtime User
Just one thing is, you mentioned in an earlier post about checking the aps.cer file and the bundle ID. When I look in the aps.cer, my bundle
Ok, thanks. I have checked the code but will do so again. I have tried foreground and background. I will keep checking, thanks for your input, it is appreciated.


Ok, I have sorted out my problem :oops::oops::oops: = analytics.Initialize

I had forgotten to initialize the analytics. As soon as I did the messages came through :)

The good thing about this, is I now understand the Apple Certificate, provisioning system a lot better !!!!

Thanks for your help again.




Licensed User
Enviando datos al compilador remoto. Error
Out: Build settings from command line:
ARCHS = arm64
CODE_SIGN_IDENTITY = iPhone Distribution: Inversiones Alzir S DE RL (QZ4V5V6D72)
CONFIGURATION_BUILD_DIR = /Users/administrator/Documents/UploadedProjects/<user id>/Payload
OTHER_CODE_SIGN_FLAGS = --keychain <user id>
PRODUCT_NAME = Ferinpro 2019
PROVISIONING_PROFILE = f46fb132-e8f2-4a62-8be1-ab02887a87c8

note: Using new build system
note: Planning build
note: Constructing build description
CreateBuildDirectory /Users/administrator/Documents/UploadedProjects/<user id>/build (in target: B4iProject)
cd /Users/administrator/Documents/UploadedProjects/<user id>
builtin-create-build-directory /Users/administrator/Documents/UploadedProjects/<user id>/build

MkDir /Users/administrator/Documents/UploadedProjects/<user id>/Payload/Ferinpro\ (in target: B4iProject)
cd /Users/administrator/Documents/UploadedProjects/<user id>
/bin/mkdir -p /Users/administrator/Documents/UploadedProjects/<user id>/Payload/Ferinpro\

WriteAuxiliaryFile /Users/administrator/Documents/UploadedProjects/<user id>/build/ (in target: B4iProject)
cd /Users/administrator/Documents/UploadedProjects/<user id>
write-file /Users/administrator/Documents/UploadedProjects/<user id>/build/

ProcessProductPackaging /Users/administrator/Library/MobileDevice/Provisioning\ Profiles/f46fb132-e8f2-4a62-8be1-ab02887a87c8.mobileprovision /Users/administrator/Documents/UploadedProjects/<user id>/Payload/Ferinpro\ (in target: B4iProject)
cd /Users/administrator/Documents/UploadedProjects/<user id>
builtin-productPackagingUtility /Users/administrator/Library/MobileDevice/Provisioning\ Profiles/f46fb132-e8f2-4a62-8be1-ab02887a87c8.mobileprovision -o /Users/administrator/Documents/UploadedProjects/<user id>/Payload/Ferinpro\

ld: symbol(s) not found for architecture arm64
clang: error:
linker command failed with exit code 1 (use -v to see invocation)

Error: ** BUILD FAILED **

The following build commands failed:
Ld /Users/administrator/Documents/UploadedProjects/<user id>/Payload/Ferinpro\\ 2019 normal arm64
(1 failure)


Licensed User
Hi, I have this error when compiling the App, could you help me?
I followed all the steps as in the tutorial
Not open for further replies.