iOS Question Notification doesn't work when the app at the background in release app

Baris Karadeniz

Active Member
Licensed User
Notification works at the foreground and background in debug mode. In release app, notification works at the foreground but doesn't work at the background. Is it normal? If I upload the app to the appstore, does it work like in debug mode?
 

Baris Karadeniz

Active Member
Licensed User
I don't kill the app. I exactly test same in debug and release mode. In foreground and background. But in release mode when the app is background there is no notification.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Complete program that you can test:
B4X:
Sub Process_Globals
   Public App As Application
   Public NavControl As NavigationController
   Private Page1 As Page

End Sub

Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.Title = "Page 1"
   Page1.RootPanel.Color = Colors.White
   NavControl.ShowPage(Page1)
   App.RegisterUserNotifications(False, True, True)
   Dim n As Notification
   n.Initialize(DateTime.Now + 10 * DateTime.TicksPerSecond)
   n.AlertBody = "test"
   n.Register
End Sub

I've just tested it on both modes and it works (the notification will only show if the program is in the background).
 
Upvote 0

Baris Karadeniz

Active Member
Licensed User
Related codes are below. Interesting thing is; it works in debug mode completely. There is a problem with release mode when the app is background. If you want I can send all project.

B4X:
Sub JobDone (Job As HttpJob)
  Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
  If Job.Success = True Then
      Select Job.JobName
        Case "Job1"
            'print the result to the logs
            'Log(Job.GetString)
        Case "Job2"
            'print the result to the log
             Log(Job.GetString)
             If Job.GetString > 0 Then
                 Dim ln As Notification
                ln.Initialize(DateTime.Now) '(DateTime.Now + 6 * DateTime.TicksPerSecond) '6 seconds from now               
                ln.IconBadgeNumber = 1
                ln.AlertBody = AlertMessage
                ln.PlaySound = True
                ln.Register
                'hd.ToastMessageShow("Notification will fire in 6 seconds.", False)
            End If
        Case "Job3"
            'print the result to the logs
            'Log(Job.GetString)
      End Select
  Else
      Log("Error: " & Job.ErrorMessage)
  End If
  Job.Release
End Sub

Sub Application_ReceiveLocalNotification (LN As Notification)
    'this event will fire if the scheduled notification happend when the app was running
    hd.ToastMessageShow(LN.AlertBody, True)
    PlayNotification(1007)
End Sub
 
Upvote 0
Top