why UIApplicationOpenSettingsURLString is crashing on camera switch change? - camera

NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
its work fine for other settings like :
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=General&path=Keyboard"]];
or wifi or general
Its crashing with Message from debugger: Terminated due to signal 9 for only UIApplicationOpenSettingsURLString when switch state change ON/OFF
else if we don't change switch state change ON/OFF then it debug properly, visit all the delegate methods.

Related

Admob close button is upper the safe area on iPhone 12

Using Google-Mobile-Ads-SDK 7.68, users can't close GADInterstitial, the close button is upper the safe area (user interaction is not permitted here) :
It's happening at least on iPhone 12 pro and iPhone 12 pro max.
What I tried :
GADInterstitial *interstitial = [[GADInterstitial alloc] initWithAdUnitID:#"xxx"];
GADRequest *request = [GADRequest request];
[interstitial loadRequest:request];
Hiding status bar let the user click on the close button. Ugly deprecated method, but it's working for now.
/// Tells the delegate that an interstitial will be presented.
- (void)interstitialWillPresentScreen:(GADInterstitial *)ad {
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
/// Tells the delegate an ad request failed.
- (void)interstitial:(GADInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error {
[[UIApplication sharedApplication] setStatusBarHidden:NO];
}
/// Tells the delegate the interstitial is to be animated off the screen.
- (void)interstitialWillDismissScreen:(GADInterstitial *)ad {
[[UIApplication sharedApplication] setStatusBarHidden:NO];
}
/// Tells the delegate that a user click will open another app
/// (such as the App Store), backgrounding the current app.
- (void)interstitialWillLeaveApplication:(GADInterstitial *)ad {
[[UIApplication sharedApplication] setStatusBarHidden:NO];
}

iOS9: Cannot open http link with Safari from 'openurl' method

I cannot open the http link with Safari using 'openurl' method, if Safari is not opening in the background. But if Safari is running in background process, the app can open the http link with Safari successfully. I am not sure whether this is one of iOS9 changes.
Here is my code
BOOL isAppInstalled = [[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:[DELEGATE advertiseUrl]]];
if(isAppInstalled) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://stackoverflow.com"]];
}

Local Notification: No Permission to Play Sound Even After Registering fo UIUserNotificationTypeSound

"Attempting to schedule a local notification UIConcreteLocalNotification: with a sound but haven't received permission from the user to play sounds"
- (void)registerForRemoteNotifications
{
if ([[UIApplication sharedApplication] respondsToSelector:#selector(isRegisteredForRemoteNotifications)]) {
// iOS 8 Notifications
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert|UIUserNotificationTypeSound|UIUserNotificationTypeBadge) categories:nil]];
} else{
// iOS < 8 Notifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIUserNotificationTypeAlert)];
}
}
//added for ios8
- (void)successfullyRegisteredUserNotificationSettings
{
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
I followed the guide of other users in stackoverflow to use registerUserNotificationSettings for ios8. After invoking the function, I wait for the callback in AppDelegate:
- (void)application:didRegisterUserNotificationSettings:
In the function, I call my successfullyRegisteredUserNotificationSettings method above to formally register.
Even after doing this, I still get the error. Can someone tell me why? Or has anyone encountered the same issue? How can this be solved?

Opening URL in browser by clicking button

Hi friends,
I am getting data from server when user post a link on his timeline am displaying like this but my requirement is when i click Title then it will open browser. How can i do this?
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.stackoverflow.com"]];
Will open a URL by the Application defined for the scheme. http has Safari as default (I guess)
To open it in the App itself create a ViewController + xib,
add a UIWebView to your View
& Buttons to get back to the app.
Then you can create an instance of your new ViewController and present it with
[self presentViewController:WebVC animated:YES completion:^(void){
[[WebVC MyWebView] loadRequest: [NSMutableURLRequest requestWithURL:[NSURL URLWithString: #"http://stackoverflow.com"]];
}];
e.g.
To make it even easier you could add a function to your ViewController like this one
-(void) LoadUrlFromString: (NSString *)url{
[self.MyWebView loadRequest: [NSMutableURLRequest requestWithURL:[NSURL URLWithString: url]]];
}
and then just do as before but call
[WebVC LoadUrlFromString:#"http://stackoverflow.com"];
on completition
You can use TTTAttributedlabel
TTTAttributedlabel *title_lbl = [TTTAttributedlabel alloc]init] //Make it an instance of TTTAttributed label what you are using for displaying the Title.
NSRange range = [title_lbl.text rangeOfString:"YOUR_TILE_HERE (Latest bollywod and hollywood.....")"];
[title_lbl addLinkToURL:[NSURL URLWithString:#"YOUR_URL_HERE (www.bollywood.com)"] withRange:range];
title_lbl.delegate = self;
And for onlcick method
- (void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url
{
NSlog("%#",label.text);
[UIApplication sharedApplication] openURL:url];
}

iPhone sdk - open app store to specific app?

Is there a way to open the app store to a specific application?
I tried using something like the following:
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:#"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=284417350&mt=8&uo=6"]];
But got the following: "Safari cannot open the page because to many redirects occurred".
Apparently this issue only affects the simulator. A build an go on the device works perfect.
Use http://itunes.com/app/YourAppNameWithoutSpaces
See also this.
Another simple way is:
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:#"itms-apps://itunes.com/app/YourAppNameWithoutSpaces"]];
This is very clean
You can open app without opening safari
NSString *appId = #"you appid"; //like 999999999
NSString *link = [#"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=" stringByAppendingString:appId];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:link]];
Replace iTunesLink with your App URL.
NSString *iTunesLink = #"https://itunes.apple.com/us/app/digital-speedometer-pro/id1021728349?mt=8";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
Starting from iOS 6 right way to go is using SKStoreProductViewController class.
Code is here: https://stackoverflow.com/a/32008404/1151916