text in UIActivityviewcontroller non-editable - swift

I Made a game where the player can share its highscore with an UIActivityviewcontroller. But when pressed share with facebook for example, there comes a screen where the player can edit the text that I have set, So if I set level 9, the player can change it self to level 120.. How can I avoid this?
The piece of code I am using for the sharing:
let text = "I made it to level /(level)!"
let actviewcon = UIActivityViewController(activityItems: [text], applicationActivities: nil)
self.presentViewController(actviewcon, animated: true, completion: nil)

If you're going to use UIActivityViewController and permit a built-in activity like Facebook, you cannot alter or prevent the user's interaction with that activity's built-in interface.
So, if you don't like that, and you want to allow the user to post to Facebook, you would need to provide your own interface for doing that. You can post directly to Facebook yourself on the user's behalf thanks to the Accounts framework which lets you employ the user's credentials without seeing them.

Related

Swift openURL change text of return to app and persist website login

I am very new to Swift, so please excuse any mangled terminology.
In my application, the user scans a barcode which encodes a url. I then redirect them to that website with
if #available(iOS 10.0, *)
{
UIApplication.shared.open(url!, options: [:], completionHandler: { (success:Bool) in })
}
else
{
UIApplication.shared.openURL(url!)
}
In the topleft corner of the safari browser, there is a little arrow with the name of my App. If you click it, it returns to my app.
I'd like to change that text to "Done" rather than the name of my app.
Also, if the site I redirect them to requires a log in, that's fine. But after they login, on the next scan, it asks them to login again. How can I make the login persistent?
First, app name on top left corner is default behavior of deeplinking. You can't change that to 'done'.
Second, If I got you right you can save the 'data' in cookies, session or any stateful area so that you can fetch it after login.

how to add a custom entry in UIActivityViewController

When i open an attachment from iPhone or iPad mail application, there is a popup that can transfert the file to a third party application.
This iOS popup is called UIActivityViewController.
I wand to add my own iOS application (written in swift) in this popup and i do not know how to do...
Thanks
I believe you are asking about two separate things.
UIActivityViewController:
Here's my code in my app.
let vc = UIActivityViewController(activityItems: [shareImage], applicationActivities: [])
vc.excludedActivityTypes = [
UIActivityType.airDrop,
UIActivityType.assignToContact,
UIActivityType.addToReadingList,
//UIActivityType.copyToPasteboard,
//UIActivityType.mail,
//UIActivityType.message,
//UIActivityType.openInIBooks,
//UIActivityType.postToFacebook,
//UIActivityType.postToFlickr,
UIActivityType.postToTencentWeibo,
//UIActivityType.postToTwitter,
UIActivityType.postToVimeo,
UIActivityType.postToWeibo,
UIActivityType.print,
//UIActivityType.saveToCameraRoll
]
present(vc,
animated: true,
completion: nil)
vc.popoverPresentationController?.sourceView = self.view
vc.completionWithItemsHandler = {(activity, success, items, error) in
}
Pay attention to the excludedActiviyTypes code. My app is an image effect app, so I commented out the things I wish to have in the popup - Weibo, print, assignToContact, ReadingList, Vimeo, and TencentWeibo. Here's the thing - I kept the full list of activities for quick reference. (I've never found it on ADC and end up getting it by using code complete.)
UIActivityType is an extended struct, so if you want to go the route of using it this way I think you'll have to (1) subclass UIActivityViewController, (2) write your own extension to UIActivityType, and (3) provide any/all code needed to use a service that isn't listed above.
A Document Provider is what I think you are looking for. Either that, or Universal - sometimes called Deep - Linking. (The links are to Apple documentation for using each.)
I've obviously used UIActivityiewController, but haven't (yet) had any need to these other two.
If you have questions about setting up a UIActivityViewController, post them in the comments. If someone else has a way to "extend" it in any way other than I described, let me know and I'll remove this answer.

Is it possible to show the app UI portion of iOS sharing extension into a page control in SWIFT?

I am using the following code to share text using iOS sharing extension (UIActivityViewController).
let vc = UIActivityViewController(activityItems: ["File URL"], applicationActivities: [])
presentViewController(vc, animated: true, completion: nil)
It shows a popup to share using text sharing applications like following:
But, I want the sharing app portion in my view into a page control like below:
How can I do this? If there is any alternative way to achieve this requirement, kindly suggest.

Share image On facebook in watchKit using the Social sdk

i want share the image on Facebook in iWatch kit now problem occur in one line need help
if SLComposeViewController.isAvailableForServiceType(SLServiceTypeTwitter) { var twitterSheet:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
twitterSheet.setInitialText("Share on Twitter")
self.presentViewController(twitterSheet, animated: true, completion: nil)
}
Now problem in last line code the error is this classname does not have a member name presentViewController
There's a few issues here:
WatchKit does not include the Social framework.
WKInterfaceController does not include the method presentViewController.
You may want to look into using Handoff to share the item from the user's phone, instead.

iOS ShareKit, twitter logout? facebook status empty?

I am using ShareKit plugin for iPhone to enable social sharing for the application I'm working on. I set up everything, I stripped it to have Facebook and Twitter services only, connected successfully to both and now I have 1 problem in each of the services...
The problem with Twitter is how to logout/signout...
ShareKit sends the text and the url to Twitter's publish box. It is saving status perfectly. The question is where to put "logout" button for twitter? I want the iPhone user to logout in order to change username. This is done by calling the method
[SHKTwitter logout];.
Now, the problem is where to put the button that will fire this method? In navigationToolbar of Twitter actionSheet I already have 2 buttons and the toolbar (bottom one) is covered by the keyboard?
[EDIT]: I solved this issue by modifying the twitter action sheet. I resized the textView and then added UIToolbar and changed its position so that it fits into the gap between the keyboard and textView. Into the toolbar I added one button with an action that calls a logoutTwitter method
Facebook problem is more of a mystery...
So, in my sharreKitButtonHandler I have the following code:
NSURL *url = [NSURL URLWithString:#"http://www.domain.com"];
SHKItem *shareItem = [SHKItem URL:url title:self.itemTitle.text];
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:shareItem];
[actionSheet showFromToolbar:self.shareKitToolbar];
This code prepares some ivars of a shareItem object and in the case of Twitter shareKit manages to fill the status box so that user just needs to press publish and its done...
In the case of Facebook it is not working. FB dialog pops out and the share box is empty saying "What's on your mind?" The url and the title are not put into the publish form?
So, please if you have any clue what's going on in the latter problem or how to solve the former problem, I would really appreciate your help...
It takes five lines to add twitter. I wouldn't bother with Sharekit for that.
TWTweetComposeViewController *tweetView = [[TWTweetComposeViewController alloc] init];
[tweetView addImage:imageToShare;
[tweetView addURL:URLToShare];
[tweetView setInitialText:messageToShare];
[senderViewController presentViewController:tweetView animated:YES completion:nil];
I wanted to use sharekit for my projects, but it was difficult to use and after a week I gave up as I couldn't share more than one thing at the same time (URL, Image, Message, etc.) which is pretty useless if you want to promote your app.
Facebook is more difficult, probably a 100 lines. It took me 3-4 days to implement. It will be integrated in iOS 6 just like Twitter :)