lua-lgi libnotify add_action callback not being called - lua

I followed the hello world example on this page to set up lua-lgi and libnotify, successfully getting a notification that looks and acts the samea s if using os.execute("notify-send..."). Notify-send does not allow user actions, from what I've gathered, so I am attempting to directly use the libnotify library to display a notification with a button. When clicked in the notification, it should open a file. I am able to call the function described here with lua, using (building from the hello world example):
Hello:add_action("button", "Open", function(notification, action, user_data) os.open("gedit tmp") end)
which successfully displays a button with the label "Open" in the notification. However, the callback function is not called, so the file does not open. I also noticed when running the script, it actually finishes executing before the notification has fully appeared, so if the program is not running anymore when the button in the notification is clicked, then that's one reason why the callback isn't being called, if it's working correctly up until that point. This is my first experience with lua-lgi, so I'm not sure how these types of callback functions translate into lua, or if they're even supported, which is probably what I'm really trying to understand here. Any help is appreciated regarding this issue, or insight into an alternative to displaying a notification with a button and callback via other means.

Related

IOS expo push notifications in app killed state

To give more clarity on the issue, i am developing this for IOS using expo push notifications and react-navigation v6 along with expo sdk44 in my current project.
I am having an issue when the user interacts with the notification while the app is in a killed state (the notificatiosn arrives succesfully with all of the data), what im having trouble with is, i want to navigate the user to a specific screen. The problem is because my navigationRef is null. Here i need to mention i did not create a seperate RootNavigator. Like it is shown here https://reactnavigation.org/docs/navigating-without-navigation-prop/ .
What would be the "proper" way of handling this? So far i've tried putting all of the relevant push notification listener code inside NavigatonContainer's onReady callback ( this worked).
I also tried making a seperate useEffect and changing the state of a isReady variable and setting its new value in <NavigationContainer ref={navigationRef} onReady={() => {setNavigatorReady(true)}}> to force a rerender and thus running the code inside useEffect again. (this approach did not work)
Just to sum up my current problem. When the user interacts with a notification while the app is in a killed state i want them to be navigated to a specific screen.
Thanks in advance.
I too am using react-navigation 6.x and expo. To tackle this problem I pretty much followed this section on expo's docs: https://docs.expo.dev/versions/latest/sdk/notifications/#addnotificationresponsereceivedlistenerlistener-event-notificationresponse--void-void.
It shows you how to implement addNotificationResponseReceivedListener which is called whenever a user interacts with a notification. It works in all situations, even when the app is killed, which is the specific situation you are interested in.
The docs also show you how to integrate this listener with react-navigation. Link: https://docs.expo.dev/versions/latest/sdk/notifications/#handling-push-notifications-with-react-navigation

Cordova: Hybrid iOS App Pause event doesn't get fired when making a phone call

Does the iOS app go to the background when we make the call using tel://123456789 ?
I have an iOS app that requires to log any outbound event happening through our app (like sending mail, calling, etc).
For Calling
we use some thing like :
in this case dialler opens up and makes the call but pause or resume events never gets
triggered . So basically we dont have hook/event after the call was ended to make the log
entry for call .
Though while replicating the same flow on android proper events(resume, pause) gets fired.
For Mail
we use some thing like :
in this case mail client of the user gets opened and our hybrid app goes to background and once mail is sent and the user returns to the app "resume" event gets fired
We need something similar for the phone call. Any pointers will be really appreciated.
You could try to listen to the click on the a tag then trigger that event yourself if it is not triggered by Cordova, that way you don't have to change your code. Using jQuery:
$('your_a_tag').on('touchstart', function(event){
$(document).trigger('pause');
});
Alternatively, you could open a support ticket on cordova-ios repo.

Why is my "AppLifecycleState" "resumed" twice?

I am using call_number plugin to make a call from my app. I am tracking the AppLifecycleState to take actions. This is the order in which states are changing-
AppLifecycleState.inactive
AppLifecycleState.resumed
AppLifecycleState.inactive
AppLifecycleState.paused
AppLifecycleState.inactive
AppLifecycleState.resumed
Last 4-I understand the flow, but I am unable to understand why is state changing to resumed the first time. According to the documentation - "The application is visible and responding to user input." when it is in resumed state but when I press button, call is directly placed.
I wonder if it is being done by the plugin in background but I don't see my app coming up even for a split second.

userNotificationCenter(_:didReceive:withCompletionHandler:) not be called when a notification action is selected

I am trying to get actionable notifications working and I have gotten the actions to display when the notification is expanded, but I cannot get the delegate function to be called when I select an action. I am declaring self.notificationCenter.delegate = self in application(_:didFinishLaunchingWithOptions:), and, if I'm understanding correctly, when an action is selected it should call userNotificationCenter(_:didReceive:withCompletionHandler:), passing in the UNNotificationResponse object. But that method never gets triggered in my code. Any ideas why that may be happening?
The method you have mentioned above gets called as soon as you receive notification.
The method which is executed after clicking on action on notification is,
application:handleActionWithIdentifier:forRemoteNotification:completionHandler:
I figured out the issue. To handle notifications with content you have to add a service extension as a new target in the project. The last thing I ran was the service extension so the debugger wasn't stopping at breakpoints in the main app. I didn't know service extensions are essentially treated like completely separate apps. Since I was still in the process of working on the content of that method, what was in there was not working and it was hitting the breakpoints, so I thought it was not calling that function like it should.

Monaca Push Debug App

I am working on an app using Monaca where I need to be able to push notifications to users of the app. I tried getting the monaca push back-end working, and that wouldn't work, the app didn't register. I then moved to using the standard cordova plugin, so I can push directly from my servers, without using monaca's back-end. when I call the init function, normally a register event will fire, this works fine when I build the app. However I very much want to get the custom debugger working, I am able to build the custom debugger, and I see the plugin properly installed. Also the init function gets called, as soon as it is called I get the standard IOS security alert to grant the app permission, however the register event is not fired, therefore I am unable to get the device ID to push to the custom debugger app. Has anyone been able to use push notifications with the custom debugger application?
Best,
Peter
(https://github.com/phonegap/phonegap-plugin-push)
P.S, i calls to set the badge count setApplicationIconBadgeNumber works fine in the debugger. I think this is something simple, maybe with the certs? I dont get any errors fired, no notifications no clues using the standard debugger, how can I hunt down what the issue is?
I can get it work using ngCordova, which is AngularJS integration.
http://ngcordova.com/docs/plugins/pushNotifications/
Then, inject it like
var app = ons.bootstrap('myApp', ['onsen', 'ngCordova']);
Get back to me if you need further clarification.

Resources