I want to be able to have social icons in a scrollView, which when clicked, functions the same way it would if I had clicked on them after presenting a UIActivityViewController.
Actually I did exactly the same, but this solution need you to also implement side server for continues support for new apps that pops on AppStore (without update your app for everytime you need/want to add/remove new app to/from the list)
1st: You need to decide what are you going to share on other apps
2nd: you need to find out the URL Scheme that apps work with,
example for instagram -> "instagram://user?username=your_username"
3rd: now the logic behind the process
let's say i want to show facebook, twitter, slack and instagram,
let's set dictionary with relevant URLs:
["facebook":"facebook://blablabla", "twitter":"twitter://blabla", "slack":"slack://blabla", "instagram":"instagram://blabla"]
ALSO YOU NEED TO HOLD THE APP's ICONS (locally or server/firebase/cloud) - to display later on your scrollview(horizontaly collectionview or what ever you decide to use)
4rd: you need to check if that apps are installed on the device:
So just loop on your apps array/dictionary (or what ever you decide to hold your info and check for availability like that:
let instagramHooks = "instagram://user?username=your_username"
let instagramUrl = URL(string: instagramHooks)
if UIApplication.shared.canOpenURL(instagramUrl! as URL)
{
//The app are installed you can show her
} else {
//The app doesn't installed -> don't show it on the list
}
After that you just need to put their icons to UICollectionView / UIScrollView and when user tap on icon you go and open that scheme:
UIApplication.shared.open(instagramUrl!)
About how the target app will show the dialog (like UIActivityViewController action or actually open the app i don't now), but I'm sure you can find here someone that help you with that
Hop you understand my steps, if not you can contact with me for more explanation