I am trying to share something via the branch.io share sheet:
let shareText = "Some Share Text"
let linkProperties = BranchLinkProperties()
linkProperties.feature = "Some"
linkProperties.addControlParam("$desktop_url", withValue: desktopURLString)
linkProperties.addControlParam("$android_url", withValue: androidURLString)
let object = BranchUniversalObject(canonicalIdentifier: "some.cannonical.identifier")
object.title = "Some Title"
object.imageUrl = someImageURL
object.contentDescription = "Some Content Description"
object.addMetadataKey("some_id", value: identifier)
object.showShareSheet(with: linkProperties,
andShareText: shareText,
from: self,
completion: completion)
All works great, except that the Facebook Messenger app does not show as option in the share sheet. Neither in the suggested options nor under 'More'. What is needed to achieve that?
I found the following question / answer for the default UIActivityViewController. How does that work with branch.io though? Facebook Messenger not showing up with UIActivityViewController
When you share via a share sheet on iOS - whether you use the Branch share sheet or UIActivityViewController - the choice of sharing options is not yours to define, it is defined by the user.
The interface for setting which apps will appear on the list can be accessed by opening a Share Sheet and then scrolling through the list of presented apps until you see the "..." (More) option. Tap on this button and you will be presented with the list of apps that can be shared to on the phone:
Each app will have a slider - if the slider is enabled for a particular app, that app will appear in the list.
Enabling Facebook Messenger for sharing on a user's phone is not something you can do from within your app as a developer.
You mention that the Messenger app is not even available when you tap the More button. This strikes me as odd; every device I check does have Facebook Messenger as an option if it is installed. Perhaps try removing and reinstalling Facebook Messenger.
I dived into the issue once more and I finally found the trouble maker. If I set feature of the branch link properties to a string value containing a space, Messenger disappears in the share sheet. The example:
let properties = BranchLinkProperties()
properties.feature = "Share News" //does not work, messenger does not appear in the share sheet
//properties.feature = "Share_News" //works, messenger appears in share sheet
object.showShareSheet(with: properties, andShareText: "Some Share Text", from: viewController, anchor: UIBarButtonItem()) { (activityType, completed) in
if (completed) {
print(String(format: "Branch TestBed: Completed sharing to %#", activityType!))
} else {
print("Branch TestBed: Link Sharing Cancelled\n")
}
}
feature is used as a parameter in the URL in Branch which is then given to the sharing extension. While this, I think, is an encoding issue in Branch, it seems that the Messenger sharing extension is not handling the URL in the same way as other apps. The 'broken url' does work with other sharing extensions. Hope this helps someone else! I will change the name of my feature to something without space for now.
Related
I'm developing an iOS app with swift and I need to share a message with the telegram app when a button is pressed. I want the user to choose which contact he/she wants to share the message with.
I've tried the "tg://msg?text=" schema but it only opens telegram not the sharing page to choose a contact.
Does anyone know a way for doing this?
Thank you in advance for your help !
Answer:
As #Cesare pointed out the tg://msg?text=test URL had been disabled by telegram so we need a specific phone number to share the message with.
Telegram disabled the tg://msg?text=test URI. You can only send direct messages to pre-chosen users or contacts.
So you may want to present a standard contact list and then send a message to that phone number (assuming they have Telegram).
For sure if you use a UIActivityController that should work.
#objc func didSelectShareRow() {
let text = "Hello"
let textShare = [text]
let activityViewController = UIActivityViewController(activityItems: textShare , applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view
self.present(activityViewController, animated: true, completion: nil)
}
Another solution would be to use something like my LNExtensionExecutor, which allows you to bypass the UIActivityViewController and execute the standard Telegram (or any other) share extension, providing text and/or images as input items.
Im using TwiterKit 3.0 framwork. And im using Deeplink to share a tweet for my application. But the problem is its presenting a new viewController and shows the twitter dialogue box. But my requirement is need to share like in Photos app sharing screen.
if let deepLinkurl = branchObject.getShortUrl(with: shareLinkProperties) {
let composer = TWTRComposer()
composer.setURL(URL(string: deepLinkURL))
composer.show(from: self) { result in
if (result == TWTRComposerResult.cancelled) {
print("Tweet composition cancelled")
}
}
If i run above code I get like this
But I need something like this.
You can use Branch's showShareSheet() method for sharing Branch links to other apps.
Here is how the link is shared when using the shareSheet and selecting Twitter from the list of the Apps.
You can check out the documentation here
I am fairly new in Google Analytics in general, so please be patient with me and my questions.
If I am using the Google Analytics for web, by putting in the tracking code in my web header, GA will automatically collect data (visitors, page view, sources, etc)
For mobile app, I need to put the plist (iOS) or json (Android) into the build and compile.
My understanding is that it's not enough just by putting the plist or json file into the app, right?
I would need to implement each and every single thing I want to track. For example, if i want a pageview (screens), then I would need to implement it inside my app code
https://developers.google.com/analytics/devguides/collection/ios/v3/screens
so it's not automatic like in web, where I put the script on header and it works right away.
Is that correct?
I haven't used GA for web, so I can't compare it to GA for mobile.
But I believe you are correct that you need to implement everything you want to track.
It's not too difficult. Using GA 3.11 for iOS, in Swift 3.0, the first thing I do is set up the shared GA instance in my app delegate's didFinishLaunchingWithOptions method:
GAI.sharedInstance().trackUncaughtExceptions = true
GAI.sharedInstance().dispatchInterval = 120
GAI.sharedInstance().logger.logLevel = GAILogLevel.info
GAI.sharedInstance().tracker(withTrackingId: "YOUR GA ID GOES HERE")
To track a screen view, I do this in viewWillAppear of each view controller:
if let tracker = GAI.sharedInstance().defaultTracker {
tracker.set(kGAIScreenName, value: "YOUR SCREEN NAME GOES HERE")
tracker.send(GAIDictionaryBuilder.createScreenView().build() as [NSObject : AnyObject])
}
To send an event:
let tracker = GAI.sharedInstance().defaultTracker
tracker?.send(GAIDictionaryBuilder.createEvent(withCategory: "YOUR CATEGORY", action: "YOUR ACTION", label: "YOUR LABEL", value: NSNumber(integerLiteral: YOURINTEGERVALUE)).build() as NSDictionary as [NSObject : AnyObject])
Setting custom dimensions and sending screen views with dimensions is similar. That's about as far as I've gone with GA.
I have this simple piece of code to display a sharing dialog for a number of social avenues:
let text = String(format:NSLocalizedString("I %# with the Dhammapada verse \"%#\"", comment:"$ to be composed with $$"), part, verse)
let url = URL(string:"http://www.ipuja.net")
let image = buddhanetImage.image ?? UIImage(named:"Icon-72")
let shareController=UIActivityViewController(activityItems:[text, url!, image!], applicationActivities:nil)
shareController.excludedActivityTypes = [UIActivityTypeAssignToContact, UIActivityTypeAddToReadingList,UIActivityTypePostToVimeo];
if (UI_USER_INTERFACE_IDIOM() == .pad){
shareController.popoverPresentationController?.sourceView = self.buddhanetImage;
}
self.present(shareController, animated:true, completion:nil)
Yet the tool woks fine for Google and Twitter, but when I try to share the contents on Facebook, just the url is shown without either text of image.
I checked that doing the thing on Photos and other other third party apps allows to display the full content even for Facebook, so what is missing in my code for that to work?
The URL will override the text and image when sharing to Facebook from a third-party application. Remove the URL and the image and text will appear. Also, if you have multiple hashtags in your text, only the first hashtag will be applied.
Prior to iOS 9, prefilling the Facebook share dialog with text, image, and URL was possible. Once iOS 9 was released, prefilling any fields when sharing to Facebook was not possible at all. Sometime around iOS 9.3 they reenabled prefilling fields, but prefilling all the fields is not possible.
The Stack Overflow app detects the name of my jailbrokenly-set default browser (Chrome). How can I achieve the same thing in objective-c and swift?
(Just the name, not the ActivityView code)
Example:
Update: I went into Settings > Stack Exchange and found this:
It looks like the app defaults to Safari, but iff Chrome is installed then links will be sent to that browser. Chrome is most likely detected by the canOpenUrl method described in the answer below.
I suspect that the Stack Exchange app isn't checking for your default browser specifically. After all, since Apple doesn't provide an easy way to change your default browser, I doubt the SDK provides an API to detect the default browser.
Instead, the Stack Exchange app may use the canOpenURL(_:) method on UIApplication to test if a predetermined set of common browser apps are installed. For each browser that is installed, the action sheet gets a new button. That approach could resemble the following code snippet.
let safariURL = NSURL(string: "http://stackoverflow.com")!
let chromeURL = NSURL(string: "googlechrome://stackoverflow.com")!
let operaURL = NSURL(string: "opera-http://stackoverflow.com")!
let sharedApplication = UIApplication.sharedApplication() // convenience
if sharedApplication.canOpenURL(safariURL) {
// add "Safari" button to action sheet
}
if sharedApplication.canOpenURL(chromeURL) {
// add "Chrome" button to action sheet
}
if sharedApplication.canOpenURL(operaURL) {
// add "Opera" button to action sheet
}
// display action sheet