iOS Question Remote Notification> UserNotification_Action with more than one parameter

Angel Garcia

Licensed User
Hello all,
Maybe this is a silly question, i was able to implement silent notifications and regular push notifications. Im using the UserNotificationClass from Erel.
My problem is that when the user clicks on any action of the buttons it only gets the actionIdentifier string (that is the button name), but in some cases depending on the pushed notification I need to use extra information to perform other actions, i was able to send this additional information inside the JSON 'data' node sent from server, and received correctly in the Application_RemoteNotification event, but this extra information is not stored in the "CreateAction" routine from the UserNotificationClass, so, when the user clicks on any action i just see the actionIdentifier.
So, when i debug the code and when the UserNotification_Action trigers i was able to see for a few seconds that inside the treeview of the native object there is the information needed Inside _request and inside _identifier tags, i tried to retrieve it using nativeObject with the GetField method, but the App crashes. There is a way to get this info??, or there is another way to get the proper information of the identifier and the button actions??. Please help!!

Many thanks to all in advance!

Here my code:

Public Sub Application_RemoteNotification (Message As Map, CompletionHandler As CompletionHandler)
    Dim elTitulo As String=Message.Get("title")' mapa1.Get("title")
    Dim elCuerpo As String=Message.Get("body")
    Dim laYave As String=Message.Get("yave")'Here I receive additional info
    Dim elAviso As String=Message.Get("aviso")'here too
    If laYave<>Null And elAviso<>Null Then
        Select elAviso
            Case "A"'
                UNC.SetCategoryActions("cate1",Array("Dejar de recordar"))
                UNC.CreateNotificationWithContent(elTitulo, elCuerpo, laYave, "cate1", 4000)'Here i send as an identifier the a key string to use later if the user clicks on any action'
                'additional cases below'
            Case "B"
            Case "C"
            Case "D"
            Case "P"'
            Case "X"
            Case Else
        End Select
    End If
End Sub

User Notification action event:
Public Sub UserNotification_Action (Response As Object)
    Dim n As NativeObject = Response
    Dim ActionIdentifier As String = n.GetField("actionIdentifier").AsString
    'this were different attemps to get the info below the identifier key i see in the debug for a few seconds, i see the information is there, i just need the correct method to get it'
    'Dim no As NativeObject=n.GetField("_request")
    'Dim ni As NativeObject=no.GetField("content")
    'Dim elcat As String=ni.GetField("categoryIdentifier").AsString
    'Dim micat As String=n.GetField("categoryIdentifier").AsString'
    'Dim eliden As String=n.GetField("requestWithIdentifier").AsString
    'Msgbox($"User clicked on : ${ActionIdentifier}"$, "")
End Sub

Angel Garcia

Licensed User
The problem is that the ActionIdentifier is the same in the code as the title of the button, so when the user clicks on a button I just can get the clicked button, but not any other parameter. I think i'm missing something because in the code line below the 'laYave' variable is sent as the Identifier, but is not able to retrieve it back in the UserNotification_Action Event
UNC.CreateNotificationWithContent(elTitulo, elCuerpo, laYave, "cate1", 4000)

Let me clarify my situation, i sent a push notification to the user to confirm or reject an appointment, and i send inside the JSON, the title, body and a reservation ID, 2 buttons are created on this case one to confirm and one to reject the appointment, in the UserNotification Event i was only able to get which button was clicked but not the ID of the reservation. On any case i think i need a minimum of 2 parameters: on retrieve which button was clicked and other one to perform operations based on an ID.

I have seen that inside the native object in the '_identifier' node there is the 'laYave' variable with the information but i was not able to get it.
There is any way to accomplish this?? Heelp

Any help would be appreciated
Upvote 0

Angel Garcia

Licensed User
Yes, but this also doesn't work because it just handles action done by the button, that is linked just to the title, one on one, and the ID is missing.

This second link, gave me the solution:

Finally found out the way to get the Identifier and category assigned in the UNC methods:
Public Sub UserNotification_Action (Response As Object)
    Dim n As NativeObject = Response
    Dim ActionIdentifier As String = n.GetField("actionIdentifier").AsString
    'this methods get the notification content in case there is any
    Dim no As Object = n.GetField("notification").GetField("request").GetField("content").GetField("userInfo")'
    Dim ni As NativeObject=n.GetField("notification").GetField("request").GetField("content").GetField("userInfo")
    'this methods get the category identifier and identifier'
    Dim Category As String= n.GetField("notification").GetField("request").GetField("content").GetField("categoryIdentifier").AsString
    Dim Identifier As String=n.GetField("notification").GetField("request").GetField("identifier").AsString
    End sub

Thank you Erel!
Last edited:
Upvote 0