iOS Question No Firebase_Notifications while in background?

mystic

Member
Licensed User
Longtime User
Hi,

I have Created a little App, to experiment with push Notifications, wich i plan to include in my Real Project later on.

I have includet Firebase_Notifications, orientating me at this tutorial:

https://www.b4x.com/android/forum/t...h-messages-server-not-required.68645/#content

resulting in my code:

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page
    Public FBA As FirebaseAnalytics
    Public FBM As FirebaseMessaging
   
End Sub

Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    FBA.Initialize()
    FBM.Initialize("FBM")
    App.RegisterUserNotifications(True, True, True)
    App.RegisterForRemoteNotifications
    Page1.Initialize("Page1")
    Page1.Title = "Notify-Test"
    Page1.RootPanel.Color = Colors.White
    NavControl.ShowPage(Page1)
End Sub

Private Sub    Application_Active
    FBM.FCMConnect()
End Sub

Private Sub Application_Background
    FBM.FCMDisconnect()
End Sub

Private Sub FBM_FCMConnected
   FBM.SubscribeToTopic("ios_general")
End Sub


Private Sub Application_RemoteNotification (Message As Map, CompletionHandler As CompletionHandler)
    Dim Text As Map
    Text = Message.Get("notification")   
    Log($"Message arrived: ${Message} "$)
    Log($"Text arrived: ${Text} "$)
    Msgbox(Text.Get("body"), "Push message!")
    CompletionHandler.Complete
End Sub

Now here my Problem:
Whenever my App is in the Background or Closed, i excpected it to add a Notification in the Top-Bar of the Phone.
Instead the Message gets Handeld by the "Application_RemoteNotification" as soon as the App is opened.

I want to let the user know there is something she/he should look at.
(like Facebook, or Whatapp for example)


Anyone has an Idea on what i am doing wrong?

MfG
Bastian Kramer
 

tufanv

Expert
Licensed User
Longtime User
If you are testing on ios10 and you dont have b4i v3.0 beta, it wont work because you have to add
B4X:
#Entitlement: <key>aps-environment</key><string>production</string>

You need latest b4i to compile.
 
Upvote 0

mystic

Member
Licensed User
Longtime User
If you are testing on ios10 and you dont have b4i v3.0 beta, it wont work because you have to add
B4X:
#Entitlement: <key>aps-environment</key><string>production</string>

You need latest b4i to compile.

Hi,
first thanks for replying so fast.

I checked the Versions:
B4I: 3.00
Test Phone: 10.0.2 (14A456)

Sadly after i added your suggested line in the "#Region Project Attributes"-Area (hope that was Right, but everything else starting with a # was there ...)
I couldn't Install the app at all (not in Debug or Release-Build, even Tools->Clean Project didnt help)

Phone says:
Unable to download App
"B4I example" could not be installed at
this time.
"Done" "Retry" <- Buttons

It isn`t the Connection, wLan is good, Google takes like a Quater of a Second to load.

Any Other Idae?

MfG
Bastian Kramer
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
it happens if you are using a development certificate. change the line to
B4X:
#Entitlement: <key>aps-environment</key><string>development</string>

and try again please.

Hi,
first thanks for replying so fast.

I checked the Versions:
B4I: 3.00
Test Phone: 10.0.2 (14A456)

Sadly after i added your suggested line in the "#Region Project Attributes"-Area (hope that was Right, but everything else starting with a # was there ...)
I couldn't Install the app at all (not in Debug or Release-Build, even Tools->Clean Project didnt help)

Phone says:
Unable to download App
"B4I example" could not be installed at
this time.
"Done" "Retry" <- Buttons

It isn`t the Connection, wLan is good, Google takes like a Quater of a Second to load.

Any Other Idae?

MfG
Bastian Kramer
 
Upvote 0

mystic

Member
Licensed User
Longtime User
please see post #10 of Erel's here:
https://www.b4x.com/android/forum/t...causes-not-install-problem.71858/#post-456853

I experienced the same thing in the past. You have to create a cert and provision based on the app id. maybe that is also your problem

That was Indeed the problem, it works Fine now.
I had to go back some steps and Recreat the Certificates and Provisioning File
(
Had the wrong provisioning file, thought i had created it new. obvously that wasn't the case....
But Seriously, why does Apple have to make it so Complicated?
Need like 7 Certificates for 1 App ......
)

Anyway, Thanks for helping.
 
Upvote 0
Top