ios app not visible in photos - ios

The app that I am developing needs access to the photo gallery. I have added the following code to check whether I have access to it.
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
if (status != ALAuthorizationStatusAuthorized) {
NSString *alertMessage = NSLocalizedString(#"PHOTOS_AUTHORIZATION_ALERT_MESSAGE", nil);
dispatch_async(dispatch_get_main_queue(), ^{
[[[UIAlertView alloc] initWithTitle:NSLocalizedString(#"PHOTOS_AUTHORIZATION_ALERT_TITLE", nil)
message:alertMessage
delegate:nil
cancelButtonTitle:NSLocalizedString(#"OK", nil)
otherButtonTitles:nil] show];
});
return NO;
}
return YES;
But sometimes iPhone 5s running iOS 8.4 and always iPhone 6 Plus running iOS 9 does not show my app under the privacy photos list.

Related

iOS: Strange error on phone call from App

In order to make a call from my app I used the following code:
NSString *phoneNumber = #"666666666";
NSString *phoneURLString = [NSString stringWithFormat:#"tel://%#", phoneNumber];
NSURL *phoneURL = [NSURL URLWithString:phoneURLString];
if ([[UIApplication sharedApplication] canOpenURL:phoneUrl]) {
[[UIApplication sharedApplication] openURL:phoneUrl];
} else
{
calert = [[UIAlertView alloc]initWithTitle:#"Alert" message:#"Call facility is not available!!!" delegate:nil cancelButtonTitle:#"ok" otherButtonTitles:nil, nil];
[calert show];
}
Its working as expected, but im getting the following error on the Xcode console when I run it on an iPhone:
ERROR: [AVAudioSession Notify Thread] AVAudioSessionPortImpl.mm:49:
ValidateRequiredFields: Unknown selected data source for Port iPhone
Micrófono (type: MicrophoneBuiltIn)
I searched for information about this error but I have not found anything to help me understand why is happening.
Any ideas?
Thanks
EDITED with CanOpenURL: validation.
I also noticed that im getting the error on iPhone 5 with iOS 9.2 but not on iPhone 6 with iOS 8.2.

How can I track iPhone usage like the 'Moment' app does?

How to track total usage of iPhone, even if our app is running in background(not forcefully terminated). Recently i have come across app, namely
Moment this app does track your iPhone usages, even if this app is running in background. actually they are using location service to get execution time. my question is when they get execution time, how they can be sure if user's iPhone screen lock or unlock ?
i have code to check if screen is lock or unlock
-(void)registerAppforDetectLockState {
int notify_token;
notify_register_dispatch("com.apple.springboard.lockstate", &notify_token,dispatch_get_main_queue(), ^(int token) {
uint64_t state = UINT64_MAX;
notify_get_state(token, &state);
if(state == 0) {
NSLog(#"unlock device");
UIAlertView *errorAlert = [[UIAlertView alloc]
initWithTitle:#"unlock device" message:#"test" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[errorAlert show];
} else {
NSLog(#"lock device");
UIAlertView *errorAlert = [[UIAlertView alloc]
initWithTitle:#"lock device" message:#"test" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[errorAlert show];
}
});
}
but this code is working only when app is running in foreground.
Your code is working only when app is running in foreground because when app goes in to background it is not called you have to use one of the background mode to wakeup your application can execute your code .

How to send action from my app to other app?

I want to send action from my iOS app to other app
UIApplication *ourApplication = [UIApplication sharedApplication];
NSString *URLEncodedText = #"...";
NSString *ourPath = [#"...://" stringByAppendingString:URLEncodedText];
NSURL *ourURL = [NSURL URLWithString:ourPath];
if ([ourApplication canOpenURL:ourURL]) {
[ourApplication openURL:ourURL];
}
else {
//Display error
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"..." message:#"..." delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
}
Now, open second app from my app, but I want send action to second app.
Apple added Actions to iOS8 to manage this kind of problems. You can check the docs here.
This way you can offer "services" as Actions to another apps or, if it's your case, consume that actions offered by third party apps.

How can I tell if my device doesn't see beacons?

I'm creating an iOS 7 app that will react to nearby beacons. However, I need to consider users that have an iPhone 4 or any other device that will not detect beacons. How can I tell if the device my app is running on supports beacons?
you can use CBCentral manager state. If it is CBCentralManagerStateUnsupported it doesn't support BLE.
If you want to monitor or range for beacons you might want to check if monitoring is available via CoreLocation Framework - Here is the way to do it :
if (![CLLocationManager isMonitoringAvailableForClass:[CLBeaconRegion class]]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Monitoring not available" message:nil delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles: nil];
[alert show];
return;
}
else{
//Monitoring is available
}

Check if Google Maps App is installed in iOS 6

I am trying to figure out how to handle the result of this code to see if Google Maps is installed in the app.
[[UIApplication sharedApplication] canOpenURL:
[NSURL URLWithString:#"comgooglemaps://"]];
I am creating a UIAlertView with the option in there and if it is or isn't I wish to give the user different options.
How do I take the result of the code above and turn it into a BOOLEAN?
Thanks in advance.
The result is already of canOpenURL: a boolean:
BOOL canHandle = [[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:#"comgooglemaps:"]];
if (canHandle) {
// Google maps installed
} else {
// Use Apple maps?
}
Above for iOS 9.0
Step 1. Add comgooglemaps in LSApplicationQueriesSchemes in your apps info.plist
Step 2.
BOOL isGoogleMap = [[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:#"comgooglemaps://"]];
UIAlertView *alert;
if(isGoogleMap)
{
alert = [[UIAlertView alloc]
initWithTitle:#"Get Directions"
message:#"Show Map"
delegate:self
cancelButtonTitle:#"Cancel"
otherButtonTitles:#"View in Apple Maps", #"View in Google Maps", nil];
}
else
{
alert = [[UIAlertView alloc]
initWithTitle:#"Get Directions"
message:#"Show Map"
delegate:self
cancelButtonTitle:#"Cancel"
otherButtonTitles:#"View in Apple Maps", nil];
}
alert.tag = 1010;
[alert show];

Resources