Post not yet marked as solved
Hi All,
I have coded a TCP Server packaged inside C++ static library. I am using this static library within the iOS Swift UI application. I have coded a simple UI which has a button, on click of which I want to start the TCP server (which is written in C++ and inside the linked static library). After the TCP server is started, I want to push the application to background and then run the client application which is going to interact with this TCP server from the backgrounded SwiftUI application. I want the TCP server to be running even the application goes to the background mode as I have another user interface application which is going to interact with the TCP server on the same device. I tried using background task, but I don't know whether I am doing something wrong there, or I cannot achieve what I want using the BackgroundTask functionality available in iOS.
The main thing here is, the TCP server code is in C++ inside static library and I want to start the TCP server from SwiftUI application layer. I have managed to call C++ function from Swift that part is available.
Can anyone show me the right path here ? How do I keep the BSD Socket based TCP Server active while the application is in Background mode ?
Hi there!
Please advice how I can subscribe to listening system events (Lock Screen/User log off/Device mounted/etc)?
I try to use NSDistributedNotificationCenter to do it, but I can receive only own notifications =(
This is the my test Console application:
//
// main.m
// EventsListener
//
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#include <iostream>
@interface MyClass : NSObject
-(void)subscribe;
-(void)handleNotification:(NSNotification*)notification;
@end
@implementation MyClass : NSObject
-(void)subscribe
{
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:nil object:nil];
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(handleNotification2:) name:nil object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification3:) name:nil object:nil];
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification4:) name:@"com.apple.screenIsLocked" object:nil];
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(handleNotification4:) name:@"com.apple.screenIsLocked" object:nil];
}
-(void)handleNotification:(NSNotification*)notification
{
NSLog(@"handleNotification: %@", notification);
}
-(void)handleNotification2:(NSNotification*)notification
{
NSLog(@"handleNotification2: %@", notification);
}
-(void)handleNotification3:(NSNotification*)notification
{
NSLog(@"handleNotification3: %@", notification);
}
-(void)handleNotification4:(NSNotification*)notification
{
NSLog(@"handleNotification3: %@", notification);
}
@end
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
MyClass* mc = [MyClass new];
[mc subscribe];
[[NSNotificationCenter defaultCenter] postNotificationName:@"test notification" object:nil];
NSLog(@"Press enter to abort");
getchar();
}
return 0;
}
What wrong I does?
Thanks!
Post not yet marked as solved
My IDE like app built with electron allows to spawn a terminal by means of forkpty. Although this is also working in the MAS build, the sandboxed environment results in the terminal being mostly unusable (which I expected).
From a technical perspective, what would be the best way to allow an unrestricted terminal experience? Obviously I'd need the terminal process to be spawned outside the sandboxed environment.
My initial thinking was that I could create some kind of "Helper" app that the user has to run manually. This app would then run outside the sandbox and would provide a terminal API to my sandboxed app by means of TCP or IPC Socket communication. But this would have multple drawbacks:
Uncomfortable for the user because he has to spawn the helper app
The communication sockets could be abused by others
I'm sure there exist many other apps on the Mac App Store that face the same problem (running a process outside the sandboxed environment).
What is the best way to solve this? Is it even allowed?
Post not yet marked as solved
Can we access and perform actions over the UIElements of other apps from my app in iOS?
For example: Suppose i want to access the button of Whatsapp, and Uber from my app.