How to enable/disable iphone celular network without disable WIFI - iphone

I'm working on an iPhone app and I'd like to disable phone but keep wifi working. For that i am using the code below:
`-(void) disablePhone
{
void *libHandle = dlopen(”/System/Library/Frameworks/CoreTelephony.framework/CoreTelephony”, RTLD_LAZY);
int (*enable)(int mode) = dlsym(libHandle, “CTPowerSetAirplaneMode”);
enable(1);
}
-(void) enablePhone
{
void *libHandle = dlopen(”/System/Library/Frameworks/CoreTelephony.framework/CoreTelephony”, RTLD_LAZY);
int (*enable)(int mode) = dlsym(libHandle, “CTPowerSetAirplaneMode”);
enable(0);
}`
But it is getting crashed at enable(1) and enable(0) lines.
Can anybody help me why its getting crashed?
or
is there any other solution through which I can change the mode of iphone to flight mode without disable wifi.
Thanks in advance

Due to the sandboxing of iOS apps, I would doubt this is acceptable to Apple. I would instruct the user to do it manually; it seems like the only way. They can turn off the cellular network in settings without turning on airplane mode.

Related

Switching camera from front to back in pjsip iPhone

I am working on pjsip video calling app. I want to switch preview camera in an ongoing call.
Here is the code that I am trying.
pjsua_call_vid_strm_op_param param;
pjsua_call_vid_strm_op_param_default(&param);
param.cap_dev = PJMEDIA_VID_DEFAULT_CAPTURE_DEV;
pj_status_t status = pjsua_call_set_vid_strm(_current_call,
PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV, &param);
if (status == PJ_SUCCESS)
{
NSLog(#"Toggle");
}
I am not able to switch camera using above code.
I have also added below code before adding account in pjsip
acc_cfg.vid_in_auto_show = PJ_TRUE;
acc_cfg.vid_out_auto_transmit = PJ_TRUE;
acc_cfg.vid_cap_dev = PJMEDIA_VID_DEFAULT_CAPTURE_DEV;
acc_cfg.vid_rend_dev = PJMEDIA_VID_DEFAULT_RENDER_DEV;
pjmedia_orient orient;
orient = PJMEDIA_ORIENT_ROTATE_90DEG;
pjsua_vid_dev_set_setting(PJMEDIA_VID_DEFAULT_CAPTURE_DEV,
PJMEDIA_VID_DEV_CAP_ORIENTATION, &orient, PJ_TRUE);
If there is any other method please guide me.
pjsua_call_set_vid_strm() is the correct method already, just try to change the capture device ID (i.e: param.cap_dev). Note that PJMEDIA_VID_DEFAULT_CAPTURE_DEV means the default capture device, which on iPhone normally is the front facing camera.
You can use pjsua_vid_dev_count() and pjsua_vid_dev_get_info() to enumerate available video devices. Capture devices should have direction info (pjmedia_vid_dev_info.dir) set to PJMEDIA_DIR_CAPTURE. And device name info (pjmedia_vid_dev_info.name) should tell which one is the back camera.

Recording interrupted by multitasking and content resizing

A try to start a screen recording with RPScreenRecorder. I got the following error:
Recording interrupted by multitasking and content resizing
func startRecording() {
let recorder = RPScreenRecorder.shared()
recorder.startRecording(handler: { (error) in
if let unwrappedError = error {
print(unwrappedError.localizedDescription)
} else {
}
})
}
Before iOS 12.0 everything worked fine. From the update I get the error above.
My app has been rejected from App store for the same reason. So far the only workaround is to reboot the device.
I had a similar problem and here is how I solved it.
go to project then targets then capability switch on Background mode then enable audio and VOIP. It should work
I've done a lot of research on the errors and posted the solution Here.
For now my screen recording feature is bug free. But who knows what comes with the new OS updates
We've been rejected same issue several times.
But we found a senario to re-produce as bellow,
We reported it on Resolution Center in App Store Connect, then passed.
connect iOS(12.4) device to host launched XCode 10.3
(regardless of opened related project)
cold boot iOS device.
launch app and start recording video ASAP(until 30sec after booted)
Now iOS13, we don't face this error at the above senario.

Is there any alternate solution to mute ringer programmatically?

I'm working on an iphone application which used to mute the phone ringer programmatically.Currently I'm using celestial.framework to mute,but I come across that the apple will reject using private framework.Please anybody give right solution to achieve it.I'm new to iOS development.Thanks
Class avSystemControllerClass = NSClassFromString(#"AVSystemController");
NSString *soundCategory = #"Ringtone";
float newVolumeLevel = 0.0;

jailbroken iOS: how resume(in foreground) from background

I have problem. I need solve this problem for jailbreak iOS. My application works in background mode. I want that application go to foreground mode from background after some events.
I tried next instruction:
system([[NSString stringWithFormat:#"uiopen \"%#\"", #"appname://"] UTF8String])
But application didn't run from background. App run as new process.
Thank you.
User private API:
int SBSLaunchApplicationWithIdentifier(CFStringRef displayIdentifier, Boolean suspended);
It's defined in SpringboardServices private framework.
You will need to add entitlement "com.apple.springboard.launchapplications" for this to work.

Turn off display in iPhone OS (iOS)

is there a way to programmatically turn off the display in iOS? Not just turning brightness down, but off like the way the Phone App does. I am happy to use private API, since this is for personal use.
Thanks!
You can turn off the display by enabling the proximity monitoring. It will automatically turn off the screen, like in the Phone app, by placing the phone near your ears or by placing a finger over the IR sensor at the top of the phone.
[UIDevice currentDevice].proximityMonitoringEnabled = YES;
You can do this, (obviously, using Private APIs of course) :
on iOS5:
#include <stdio.h>
#include <dlfcn.h>
int (*SBSSpringBoardServerPort)() = (int (*)())dlsym(RTLD_DEFAULT, "SBSSpringBoardServerPort");
int port = SBSSpringBoardServerPort();
void (*SBDimScreen)(int _port,BOOL shouldDim) = (void (*)(int _port,BOOL shouldDim))dlsym(RTLD_DEFAULT, "SBDimScreen");
and then use
SBDimScreen(port,YES);
whenever you want to dim, and
SBDimScreen(port,NO);
whenever you want to undim.
On iOS6:
void (*BKSDisplayServicesSetScreenBlanked)(BOOL blanked) = (void (*)(BOOL blanked))dlsym(RTLD_DEFAULT, "BKSDisplayServicesSetScreenBlanked");
and then use:
BKSDisplayServicesSetScreenBlanked(1); // 1 to dim, 0 to undim
"Dim" here means totally turn off the screen. This is what the system uses when e.g. a proximity event occurs while in a call.
The only way I know of, public or private, is using the power button.
You might look at -[UIApplication setProximitySensingEnabled:(BOOL)], or -[UIApplication setIdleTimerDisabled:YES], this might lead to something useful
Have you tried:
[[UIScreen mainScreen] setBrightness: yourvalue];
SO question 8936999: iPhone: How can we programmatically change the brightness of the screen?
Proximity doesn't work on all devices. There's a much simpler solution to this problem without resorting to private APIs.
Swift
UIScreen.main.wantsSoftwareDimming = true
UIScreen.main.brightness = 0.0
Without wantsSoftwareDimming, the backlight will never completely turn off.
The docs have this cautionary sentence:
The default value is false. Enabling it may cause a loss in performance.
I do not think there is any to turn off the display (simulating iphone sleep button) except changing the brightness.
This link might help.