How to lockScreen and unlockScreen remotely in iOS? - ios

is there any API can do it?I want to lock screen and unlock it remotely in the setting time,without password,just make the screen black and can make it bright again,the case like this:
[[UIDevice currentDevice] setProximityMonitoringEnabled:YES]
when we get the phone near our ears the screen closes,and far bright again,i just want to controll the screen lock and unlock remotely.

Related

Notification with sound and vibration when iphone is Locked

I am currently working on an iOS app and i need some help.
I want the app to be able to notify the user about something in form a "push notification" even when the phone locked. The push notifications work fine when the phone is not locked but as soon as i lock the phone it wont give me any sound or vibration. It will only show me the visual part of the notification but it comes in completely silence. It does not even light the screen up when the notification gets pushed to the user.
I currently use
content.sound = UNNotificationSound.default()
And it works fine with sound and vibration when the phone is unlocked.
Is it because i need to do something with my settings? do i need any code to do such thing? do i need to have developer account?
Any help would make me really happy!!
3 STEPS TO HOPEFULLY RECOVER SOUND ON YOUR IPHONE FOR INCOMING NOTIFICATIONS.
Check that the ringer on the left of the phone doesn’t show an orange line – indicating sound switched off. If so, slide it to the right so only white is showing. This may have fixed it.
Swipe up from the bottom of the screen to reveal symbols, music etc. Ensure that the half moon symbol is grey and not white. If it’s white touch it to make it grey – this will switch off do not disturb. This may have fixed it.
Check your settings, Do not Disturb half moon icon, ensure that Manual is off and not showing a green on icon. If it is, touch the green icon which will make it white and switch it off. This may have fixed it.
(I hope that helps, it worked for my iphone 5C as I’d inadvertently switched on Do Not disturb as shown in step 2. above.)
Just an FYI if someone else is having this same issue. I was having the same troubles getting my notifications to come through on my phone when it was locked.
I realized the issue was I was building to my physical device which was also attached to the Apple Watch I was wearing. Since my watch is set to mirror my iPhone notifications the phone didn't play them as it expected my watch to take over when was locked. However, every time you build & run your app it takes a few minutes for your watch to recognize your app and take over the user notifications.
The solution here is to either wait 10 minutes or so after building and then try firing off a notification (which should appear on your watch) OR simple take off your watch before you build & run.

In-call status bar for app

I would like to know if there is a way to make your app show a status bar when the app is performing a specific function. Sort of like Shazam does when Auto Shazam is on, but this might be because the microphone and not something in Shazam's app code but I am wondering if there is a way to programmatically achieve this. Preferably in Swift but Obj-C also works.
This isn't done directly by the app, this is done by the OS when the app is using one of a few features in the background
The bar is red when an app is using the microphone in the background.
The bar is blue when an app is accessing location in the background.
The bar is also blue when a device is connected to the Personal Hotspot.
The bar is green when the telephone (including WhatsApp) is being used.
There may be more colours for other scenarios, but these are the ones I've come across.
I don't know of a way to add this bar on demand.

Is there any way to change notification image

i want to show or change present image in notification with latest image icon, the image icon will be provided either in the notification data or saved previously in the app like this one and this one image
i want that if notification came on the IOS device then the image in the notification will show accordingly
this text from iOS Human Interface Guidelines
A banner is a small translucent view that appears onscreen and then disappears after a few seconds. Users can also see a version of the banner on the lock screen and in the Notifications view of Notification Center. In the banner, iOS displays your notification message and the small version of your app icon (to learn more about the small app icon, see App Icon). Users tap the banner to dismiss it and switch to the app that sent the notification.
I believe that you can't change it, but may be if you change some pictures in App icon source, you will achieve the necessary result, but I repeat, hardly everything will correctly work
for example
U can try to change Spotlight images or any else....

Determining statusbar orientation

I am wanting to detect where the status bar is on my current view in order to determine which segue to perform. I know the preferred way to do this is to determine the device orientation, but there are two problems with this approach for me:
1.) If the device is not angled far enough away from vertical or horizontal then there is no device orientation detected and the segue doesn't happen
2.) Under certain conditions I am going to "lock" the display orientation such that even though the physical device orientation is landscape the screen is going to be locked to portrait and I will want to perform the portrait segue I have created.
The problem is that the " [UIApplication sharedApplication].statusBarOrientation = " is not returning the actual orientation of the status bar. Is there not an easy way to detect this? Otherwise I am going to have to write a bunch of messy code to keep track of this.
Have you tried: [[UIDevice currentDevice] orientation]?
Note:
Depending on the design of your app it might be necessary to call [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]. If you do that, make sure to call [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications] at some point.
If that's not sufficient for your purpose I guess you have to manually check the accelerometer. Take a look at: Handling Motion Events for more info on how that's done.

iPad OpenGL Screen Rotation Problems (Multitasking bar and Popups not Rotating)

I'm building an application for the iPad using OpenGL and have issues with screen rotation. The application itself works fine and displays correctly in all four orientations, but other elements only partially respond to the device rotation.
OpenGL handles the rotation of the application using transformation matrices. That all works fine. The default images also display at the correct rotation.
The multitask bar, however, is not rotating as it should. It appears on the side that the application was opened in. So if I open the application then double tap the home button it is on the correct side, but after rotating the device it remains on the same side until the application is closed and reopened. When this bar is revealed the OpenGL application rotates to match the bar's position.
Dialogue boxes, such as the 'sign into game center' popup are also not correctly rotated. They seem to appear in the standard portrait orientation.
I'm not sure if there are any other specific details necessary to identify the problem but any suggestions are very much appreciated.
I seem to have put together a solution looking at snippets in some other threads. I think it's fixed the problem.
I have a main class which controls most of my application. It was already registered to receive device rotation notifications like this:
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(orientationChanged:) name:#"UIDeviceOrientationDidChangeNotification" object:nil];
I added a few lines to the orientation handler function to manually set the status bar location:
- (void) updateOrientation {
if ([[UIDevice currentDevice] orientation] < 5 && [[UIDevice currentDevice] orientation]>0) {
orientation = [[UIDevice currentDevice] orientation];
[UIApplication sharedApplication].statusBarOrientation = orientation;
}
}
The conditional limits the handler to respond only to landscape and portrait orientations and not face up and face down.
If anybody has a better solution I'd still like to hear it, otherwise, hope this can help someone else.

Resources