I swear this iOS app is going to be the end of me. I'm hitting brick wall after brick wall it seems. I cannot for the life of me get notifications to work on iOS, and I don't know where I'm going wrong. I'm over deadline on this project already and am at wits end. I managed to convince my boss that it'll be done by next week, but I've spent the last 7 hours dealing with this and have gotten no where. I beg for some guidance as this is the only functionality the app is missing other than a final polish of the GUI. Thank you all for your help in advance and I apoligize for the large and long post. If I'm missing any other information let me know and I'll post it ASAP.
Attached are screenshots of sections of the Apple Developer account stuff, and below is all the relevant sections of code. In my directory with the rest of my certificates I have the files aps.cer (the Apple Push Services certificate), ios_distribution.cer, and ios_development.cer. (See certs.png attached) I have two identifiers on the backend of the apple developer site. A wildcard called "Main Identifier" that is "com.mccoysoutdoors."* and one named "StoreApp" that is "com.mccoysoutdoors.deals". The provisioning file is iPadDevelopment.mobileprovision and a screenshot of it's properties is attached as a PNG. I have no keys setup.
I copy and pasted the code from the project in https://www.b4x.com/android/forum/threads/b4x-firebase-push-notifications-2023.148715/ to the same sections of my own app.
My GoogleService-Info.plist is in the Files/Special directory.
The code under my "Main" section is:
In "B4XMainPage" in Class Globals I added:
In "B4XMainPage" in Sub B4XPage_Created I added:
And in FirebaseMessaging.bas I added one line to the MessageRecievedWhileInTheForeground Sub:
I've also attached the Firebase Messaging Campaigns section showing the attempts I've made to try to get a notification working. The different log functions show that I'm getting at least through SubscribeToTopics as I'm getting a Token returned in my logs, but no sign of any notifications (even when trying to send to that specific token.)
Attached are screenshots of sections of the Apple Developer account stuff, and below is all the relevant sections of code. In my directory with the rest of my certificates I have the files aps.cer (the Apple Push Services certificate), ios_distribution.cer, and ios_development.cer. (See certs.png attached) I have two identifiers on the backend of the apple developer site. A wildcard called "Main Identifier" that is "com.mccoysoutdoors."* and one named "StoreApp" that is "com.mccoysoutdoors.deals". The provisioning file is iPadDevelopment.mobileprovision and a screenshot of it's properties is attached as a PNG. I have no keys setup.
I copy and pasted the code from the project in https://www.b4x.com/android/forum/threads/b4x-firebase-push-notifications-2023.148715/ to the same sections of my own app.
My GoogleService-Info.plist is in the Files/Special directory.
The code under my "Main" section is:
Main:
'Code module
#Region Project Attributes
#ApplicationLabel: McCoy's Outdoors Deals
#Version: 1.0.0
'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
'#iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
'#iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
#iPhoneOrientations: Portrait
#iPadOrientations: Portrait
#Target: iPhone, iPad
#ATSEnabled: True
#MinVersion: 12
#CertificateFile: ios_development.cer
#Entitlement: <key>aps-environment</key><string>production</string>
#ProvisionFile: iPadDevelopment.mobileprovision
#End Region
Sub Process_Globals
Public App As Application
Public NavControl As NavigationController
Public UNC As UserNotificationCenter
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Dim PagesManager As B4XPagesManager
PagesManager.Initialize(NavControl)
App.RegisterForRemoteNotifications
App.RegisterUserNotifications(True, True, True)
UNC.Initialize
End Sub
Private Sub Application_RemoteNotification (Message As Map, CompletionHandler As CompletionHandler)
FirebaseMessaging.MessageReceivedWhileInTheForeground(Message)
CompletionHandler.Complete
End Sub
Private Sub Application_PushToken (Success As Boolean, Token() As Byte)
Log($"PushToken: ${Success}"$)
If Success = False Then
Log(LastException)
End If
End Sub
Private Sub Application_Active
End Sub
Private Sub Application_Background
End Sub
In "B4XMainPage" in Class Globals I added:
Class Globals:
Private analytics As FirebaseAnalytics
In "B4XMainPage" in Sub B4XPage_Created I added:
Sub B4XPage_Created:
analytics.Initialize
Root = Root1 ' Assign the root view for the layout
' Load the layout from the MainPaage file
Root.LoadLayout("iOSMain")
CallSubDelayed2(FirebaseMessaging, "SubscribeToTopics", Array("deals"))
#if B4A
Wait For (CheckAndRequestNotificationPermission) Complete (HasPermission As Boolean)
If HasPermission = False Then
Log("no permission")
ToastMessageShow("no permission", True)
End If
#Else If B4i
Main.App.RegisterUserNotifications(True, True, True)
Main.App.RegisterForRemoteNotifications
#End If
And in FirebaseMessaging.bas I added one line to the MessageRecievedWhileInTheForeground Sub:
Sub B4XPage_Created:
Main.UNC.CreateNotificationWithContent(alert.Get("title"), alert.Get("body"), "identifer 2", "Category 1", 4000)
I've also attached the Firebase Messaging Campaigns section showing the attempts I've made to try to get a notification working. The different log functions show that I'm getting at least through SubscribeToTopics as I'm getting a Token returned in my logs, but no sign of any notifications (even when trying to send to that specific token.)