Launch app from calendar event - ios

I've seen similar question here. But it doesn't work for me. I've added my url scheme with calendar event's url property. It's pretty cool to see scheme url appeared in event's url row. But I couldn't tap on url(url scheme) as like normal url like www.google.com.
code for adding url to EKEvent
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
event.title = #"Event Test For adding url";
NSString *customURL = #"sampleEventappScheme://";
event.URL = [NSURL URLWithString:customURL];
After event added to calendar event, see screenshot for better understanding.
Note: If I try to launch app with safari using this scheme, It's perfectly worked. So there's no issue with scheme configuration.

I've resolved this issue by just extend url by event title with our app url scheme. ie. We just make it as url that is enough.
NSString *customURL = #"sampleEventappScheme://title=eventadd";
Brief explanation:
This is normal url : http://www.google.com. Here http is url scheme. As like that, in above app url, sampleEventappScheme is url scheme. When we try to hit this url, system will see scheme lookup table, if we already register our scheme, then it will switch to our app.

Related

objective c - Open with suggestions when trying to open URL schemes

I started an application that can handle SMS or Mail url schemes but I don't want to open the default apps installed. I have tried doing this
[[UIApplication sharedApplication] openURL: url];
but this opens the default SMS and Mail apps.
I tried using the UIActivityViewController
NSString *url=#"mailto:sample#gmail.com";
NSURL *schemeURL = [NSURL URLWithString:url];
NSString * title =[NSString stringWithFormat:#"Send Email",url];
NSArray* dataToShare = #[url];
UIActivityViewController* activityViewController =[[UIActivityViewController alloc] initWithActivityItems:dataToShare applicationActivities:nil]
but this doesn't prefill the recipient field with the specified email.
It would be nice if the behaviour is the same with UIActivityViewController but let's us prefill information such as recipient.
Any suggestions ?
You can use non-default apps on macos but I don't think you can do so on iOS. Have a look at e.g. https://developer.apple.com/documentation/uikit/uiapplication/1648685-openurl?language=objc .
You could try with a URL similar to below to send with a given subject and body.
#"message://mailto://sample#gmail.com?subject=Subject&body=Body"
I think if you drop the message bit it will still work. I use it like that inside a HTML page inside an app somewhere.
If you need any special characters you will have to encode them in the subject and body.

how to launch safari even when the url is not valid

I know how to launch safari using the:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.google.com"]];
But, this method returns false when the url is not valid, and nothing happens. So, I'd like to launch safari even when the url is invalid. Is it possible?
NO it is not possible to open URL (which is invalid) with safari or any other bowser in iOS or another OS, So it's better to make valid URL rather then fighting with it.
Using below code check, if the URL is valid or not.
NSURL *candidateURL = [NSURL URLWithString:candidate];
if (candidateURL && candidateURL.scheme && candidateURL.host)
{
//Open that URL using openURL method...
}
else
{
//Open any valid hardcoded URL using openURL method
}
Short answer? No.
Long answer? Technically No. But there is a workaround. If you use a redirection service/url shortener, you can hide your invalid url. For example, try this url: http://goo.gl/zRci0B
Safari will be able to open the link but it wont go anywhere. So what ever url(valid/invalid) you want to open, always wrap it with a redirection service.

How to pass query string parameters when sharing a link through Facebook iOS SDK?

I am running into difficulty sharing an article link from my iOS app to Facebook using the Facebook SDK FBWebDialogs class. The URL of the link includes query string parameters, which I am URL encoding from my iOS app before sending to Facebook.
Here is an example link that I am trying to share:
http://www.foo.com/message.html?s=This%20is%20a%20test%20&%20an%20example
Here is what Facebook shows as the link on my timeline:
?s=This+is+a+test+&+an+example
Once the link is published to my Facebook timeline, Facebook appears to be stripping all URL encoding, leaving my query string void of encoding, which causes the destination web app to not receive necessary data. Needless to say, the destination webpage has trouble consuming the query string parameters properly if special characters (&, =, etc) are not encoded properly when linked within the Facebook feed.
What is the proper way to share a link with querystring parameters? Should querystring params be passed as a separate parameter, or should they be denoted somehow within the link url?
Below is the code relevant to setting up the share parameters.
NSString *url_param_str = [NSString stringWithFormat:#"http://www.foo.com/message.html?s=%#", #"This is a test & an example"];
NSString *web_url_param_str = [url_param_str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSMutableDictionary *feedParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:#"Sharing an article", #"name",
#"This is a test title", #"description",
#"www.foo.com", #"caption",
web_url_param_str, #"link",
nil];
It looks like that Facebook has decided to scrub url query parameters when using the SLComposeViewController You have to use Facebook Share now.
https://stackoverflow.com/a/32263392/608739
#import <FBSDKShareKit/FBSDKShareKit.h>
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL urlWithString:#"http://www.foo.com/message.html?s=This%20is%20a%20test%20&%20an%20example"];
content.contentDescription = #"Text for facebook";
content.contentTitle = #"Results.";
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:self];

Facebook permissions to know if a friend uses the same app

I can successfully grab a list of friends with this NSURL, using the permissions "publish_stream":
NSURL *friendsList = [NSURL URLWithString:#"https://graph.facebook.com/me/friends
However, when I try the same thing with an added field, as in this URL:
NSURL *friendsList = [NSURL URLWithString:#"https://graph.facebook.com/me/friends?fields=installed"];
I get an error:
error = {
code = 2500;
message = "An active access token must be used to query information about the current user.";
type = OAuthException;
};
So my question is what permissions should I be asking for to make the second URL work?
Bonus question: What URL param do I include to get a small profile pic come back in the same JSON object?
Thanks :)
According to the docs, you it Requires app access_token. However, playing with Graph API Explorer, I could get this info without this permission.
You can take a look at Graph API Explorer to test.
Also, the query on the above link returns the picture field, which will have an URL with the user picture.

iOS- sharekit - settings facebook

I have a sharekit implementation where everything works fine, but if there is no account set for facebook, upon pressing the settings button, the actionsheet is just dismissed and the user is returned to the app, not to the settings page in system prefs.
How do I get the settings button to send the user to the settings page?
the code i use to init the action sheet:
NSURL *url = [NSURL URLWithString:#"http://test"];
SHKItem *item = [SHKItem URL:url title:#"test"];
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
// Display the action sheet
[actionSheet showFromTabBar:self.tabBarController.tabBar];
This is a known, unresolved issue with ShareKit. You could submit a pull request to fix it, or work around it by checking SLComposeViewController:
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
// show ShareKit
} else {
// tell them to get Facebook
}
before displaying ShareKit. Of course, that would make it so users without Facebook (like Twitter-only folks) couldn't use ShareKit. On the other hand, you could switch over to Apple's Share Sheets, or write your own, but those also have their disadvantages. Kind of a catch-22.

Resources