Share appstore url with other apps - ios

Is there any way to share web url (specifically link to an app in appstore) using UIDocumentInteractionController?
If that is not feasible what are the other options to enable the user to share the appstore url with other apps? (I am aware of ShareKit)

In this case you can use App Groups.
Create the same app group in both apps, and share with nsuserdefaults like this:
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:#"group.name"];

Related

App not opened programmatically?

I installed Meeseva app on my device. When I try to open it programmatically it's not opening.
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"Meeseva App://location?id=1"]]) {
NSString *mystr=[[NSString alloc] initWithFormat:#"Meeseva App://location?id=1"];
NSURL *myurl=[[NSURL alloc] initWithString:mystr];
[[UIApplication sharedApplication] openURL:myurl];
}
When I opened fb, twitter, google+ and etc... all are opening successfully.
Can any solve this this issue?
App link is
https://itunes.apple.com/in/app/meeseva-app/id1121539928?mt=8
Is there any another way to open installed app programatically?
If your app can receive specially formatted URLs, you should register the corresponding URL schemes with the system. Apps often use custom URL schemes to vend services to other apps.
Hence "Meeseva" app might not have created a custom url for their app. So you can't do anything for it.
As mentioned above the apps which want to provide support for url schema then they have to create a custom URL schemes.
You need to find out what the correct URL scheme of the Meeseva App is. Meeseva App:// does not seem to be a valid URL scheme as it has a space in the middle.
For example the Google Maps URL scheme is comgooglemaps://, not Google Maps://
Usually developers make their URL scheme public in their documentation. However this is a feature that needs to be implemented and apps don't support this "out of the box". If the developer did not implement this, the app can't be opened via link.
Alternatively it is possible that the app reacts on "universal links". That means if there is a website for the app, iOS might ask you whether to open that website in the app or in Safari. In that case you could simply link to the website and let the user decide how the link should be opened. However, again, this needs to be implemented by the developer. If the app does not support universal links either, there's no way for you to open the app at all.

Sharing file/data between two iOS apps that I own

I have apps A and B and both are developed by me. I want to send file from A to B but it has to happen without using any sharing services like dropbox or anything that involves internet connection.
OpenURL/CustomURLSchemes doesn't seem to work since you are limited with the data you can pass and the file size can be big. And because of the sandboxing I can't write the file and pass the url...
UIActivityViewController and UIDocumentInteractionController are options only if there is a way to display just one app which I fail to achieve so far..
Is this possible?
I own both apps and the file extension is custom.
You actually don't need extensions to share data between your own apps. You can use app groups for this.
In both MyApp1 and MyApp2 goto the target, then capabilities, then click on the app groups capability. Let Xcode help you get app group entitlement setup in your apple developer account.
Now you can use that app group ID to share data between you apps. For instance:
In MyApp1 put this in your appDelegate:
NSUserDefaults *myDefaults = [[NSUserDefaults alloc] initWithSuiteName:#"group.mycompany.myappgroup"];
[myDefaults setObject:#"foo" forKey:#"bar"];
And in MyApp2 appDelegate put this:
NSUserDefaults *myDefaults = [[NSUserDefaults alloc] initWithSuiteName:#"group.mycompany.myappgroup"];
NSLog(#"Show me something: %#",[myDefaults objectForKey:#"bar"]);
Make sure that the string you used for the suite name is the exact same as what is under the app group capabilities section in Xcode and also the string in your entitlements plist that was automatically added to your project.
You can also share files using the same idea:
NSURL *groupURL = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:
#"group.mycompany.myappgroup"];
And for those of you who want to see it in Swift:
var userDefaults = NSUserDefaults(suiteName: "group.mycompany.myappgroup")
var fileManager = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier("group.mycompany.myappgroup")

URL schemes of common iOS apps

I'd like to know if there is a list of custom URL schemes for the most popular iOS apps, such as Keynote, Numbers, Pages, Evernote, etc. I'd also like to know what parameters to use for these URLs.
The reason I need this is that I have an app on the App Store, and most users are asking me to provide 'Open With...' functionality from within the app once they select a file from their iCloud Drive.
There is a website which does exactly that: http://handleopenurl.com/.
Unfortunately, it lacks the information about parameters needed for the URLs. You can find some of them on this wiki.
Instead of using schemes you should use UIDocumentInteractionController.
If you want to open a file, you would instantiate it like this:
UIDocumentInteractionController * controller= [UIDocumentInteractionController interactionControllerWithURL:yourFileURL];
and then you can present it with:
[controller presentOpenInMenuFromRect:yourRect inView:yourView animated:YES ];
Here is a tutorial with demo project

iOS: Detect whether my SDK is installed on another apps on the device

I am developing a location based Q&A SDK for mobile devices.
When a question is asked about a specific location, the server side targets the most relevant user and sends the question to that user. If the user fails to answer, the question is sent to the second best user, and so on.
The problem is that my SDK might be installed on more than one application on the device, meaning that the user can get a question more than once.
Is there a way to detect whether my SDK is installed on more than one app? I thought that sending the UDID to the server might work, but iOS UDIDs differ between applications.
You can use UIPasteboard to share data between applications on the device.
The UIPasteboard class enables an app to share data within the app and with another app. To share data with any other app, you can use system-wide pasteboards; to share data with another app that has the same team ID as your app, you can use app-specific pasteboards.
In your SDK, do something like this:
#interface SDKDetector : NSObject
#end
#implementation SDKDetector
+ (void)load
{
int numberOfApps = (int)[self numberOfAppsInDeviceUsingSDK];
NSLog(#"Number of apps using sdk:%d", numberOfApps);
}
+ (NSInteger)numberOfAppsInDeviceUsingSDK
{
static NSString *pasteboardType = #"mySDKPasteboardUniqueKey";
NSData *value = [[UIPasteboard generalPasteboard] valueForPasteboardType:pasteboardType];
NSMutableArray *storedData = [[NSKeyedUnarchiver unarchiveObjectWithData:value] mutableCopy];
if (!storedData) {
storedData = [NSMutableArray new];
}
NSString *bundleId = [[NSBundle mainBundle] bundleIdentifier];
if (![storedData containsObject:bundleId]) {
[storedData addObject:[[NSBundle mainBundle] bundleIdentifier]];
}
value = [NSKeyedArchiver archivedDataWithRootObject:storedData];
[[UIPasteboard generalPasteboard] setData:value forPasteboardType:pasteboardType];
return [storedData count];
}
#end
If you only want to provide an SDK, it is not possible. Apple has added security steps to prevent that for user privacy. Keychain sharing will not work, because apps must share the same bundle seed ID (see here for more info).
If you want to provide an app along with your SDK, then you could do something like Facebook does, where app sends a "helo" message, Facebook asks user and finally Facebook sends "ehlo" message.
Your App -> "I would like to use the SDK; please give me token" -> SDK Controller App -> (Remember which apps have requested use) -> "OK, you can use the SDK; here is a token: #123" -> Your App
The SDK controller app can now send the server the list of apps.
I think you can group the apps on the same device by IP address as they will use the same address to connect to your server.
So the IP address will represent the device and the API key will represent the app that uses the SDK.
Can you try using
advertisingIdentifier
Not sure whether it serves your purpose. It is explained in here ASIdentifierManager class reference : Apple doc
I think its possible using keychain, you can have an unique keychain key in which you can save anything you want, and can be accessed by other apps if available. So for your SDK, lets say if there is one app, it will register some value in keychain with a unique key which is private to your SDK only if the key doesn't exist, and if it exist you get to know, since you can save any value in keychain, you can try multiple options and combinations which suits you.
You can use KeychainItemWrapper for the implementations.
Elaboration
Lets say we have an method.
[MySDK register];
Which can be used anywhere, say in AppDelegate. The register method will generate a token for the app, for the device, which we will save in the keychain using an unique key we have defined in the SDK, say in com.mysdk.key. And while saving in keychain the SDK can actually do a registration.
We consider the above method is implemented in multiple apps.
Now we have scenario.
User installs an App-A which uses the SDK, the register method will call and create a token and will save in keychain for the first time.
Now user installs another App-B which also uses the SDK, the same register method will call, but now it will check for the key com.mysdk.key in keychain, if exist it will just update the count for the token, which meant for the device.
Note
Keychain not meant to save only unique identifier, you can save other informations too.
Update
Check demo projects https://db.tt/7xpKrgMp
The wrapper I have used in the projects is same as SDK in your case which is same in both the projects.
Cheers.

Creating share buttons in iOS app ( twitter facebook...)

I was wondering what is a good way to create share buttons in iOS, and by share buttons I mean these 3 kinds of buttons:
1- Follow me on Twitter
2- Like a page on Facebook
3- Send a mail (Optional)
I have heard about sharekit but I am interested in just creating these 3 buttons that will be found on the back of the page of the app.
You can use something like:
NSString *launchUrl = #"http://twitter.com/intent/user?screen_name=USER NAME";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: launchUrl]];
which will open Mobile Safari and let you follow that user. You may be required to log in.
I guess there is a similar URL for Facebook.
To send a mail from within your app, use the MessageUI Framework.
Posting data to social services is much more complicated than just setting up a button. You must register your application, choose user, authenticate, then communicate via the internet.
ShareKit does most of that for you.
You may not just 'create share button' and have it share data to fb or twitter.
Posting to those service is complicated because you'll have to create Apps on those social networks as well as handle the oauth handshake the occurs which allows your app to share on behalf of the user. The Socialize SDK (www.getsocialize.com) is the fastest way to get Facebook/Twitter authentication without coding it yourself. Sample code below:
Socialize* socialize = [[Socialize alloc] initWithDelegate:self];
[self.socialize createShareForEntityWithKey:#"http://www.url.com" medium:SocializeShareMediumFacebook text:#"Check this out!"];
You could use ShareKit 2.0
https://github.com/ShareKit/ShareKit
I believe it supports sharing on most common social networks.

Resources