iOS Question Wait for accept to receive notifications (RegisterUserNotification)

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi everyone, there is a way to wait for the user to click on the notification dialog, so the app stops to do things?

Like:

B4X:
MsgBox2("Msg", "Body", "Title", Array("Yes", "No"))
Wait For Msg_Click (ButtonText As String)
If ButtonText = "Yes" Then
    'things'
End If

IMG_1157-min.PNG


thanks :D
 

Mike1970

Well-Known Member
Licensed User
Longtime User
No. This is a system dialog and it raises no event.
I had a doubt because I saw an app that when started it displayed that dialog and until I clicked the "yes" button it doesn't continued starting ?. After clicking it continued
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Full example:
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

End Sub

Private Sub Application_Start (Nav As NavigationController)
    'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    NavControl.ShowPage(Page1)
    App.RegisterUserNotifications(True, True, True)
    Wait For Application_Register (Settings As Object)
    Dim no As NativeObject = Settings
    Log(no.GetField("types").AsNumber) '7 = all, 0 = none
    
End Sub



Private Sub Page1_Resize(Width As Int, Height As Int)
    
End Sub

Private Sub Application_Background
    
End Sub

#if OBJC
@end
@implementation B4IAppDelegate (register1)

-(void) application:(UIApplication *)application  didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
    B4I* bi = [b4i_main new].bi;
    [bi raiseUIEvent:nil event:@"application_register:" params:@[notificationSettings]];
}
#End If
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
Full example:
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

End Sub

Private Sub Application_Start (Nav As NavigationController)
    'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    NavControl.ShowPage(Page1)
    App.RegisterUserNotifications(True, True, True)
    Wait For Application_Register (Settings As Object)
    Dim no As NativeObject = Settings
    Log(no.GetField("types").AsNumber) '7 = all, 0 = none
  
End Sub



Private Sub Page1_Resize(Width As Int, Height As Int)
  
End Sub

Private Sub Application_Background
  
End Sub

#if OBJC
@end
@implementation B4IAppDelegate (register1)

-(void) application:(UIApplication *)application  didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
    B4I* bi = [b4i_main new].bi;
    [bi raiseUIEvent:nil event:@"application_register:" params:@[notificationSettings]];
}
#End If
I saw your answer now. It seems to do what I need!!
I will try it in a moment ? thanks
 
Last edited:
Upvote 0
Top