Twitterkit present a new viewcontroller instead present on a target viewController - ios

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

Related

Create page after login xcode

I'm an XCode noob and I've looked all over for the answer. This is my first time building anything in XCode and I've created a login window using Firebase in ViewController.swift. Once the user is logged in, I want them to go to another screen that is using MapKit etc. How do I automatically link the login window success to the second page?
I've created a new cocoa touch class file as MapViewController.swift - do I just call the map function at the end of the login function or is there a more simple way to do it with the storyboard?
Sorry for the stupid question
after you check that the user enters the right credentials set function to call the new view controller
func transition() {
let mapViewController:MapViewController = MapViewController()
self.presentViewController(mapViewController, animated: true, completion: nil)
}
then call it
transition()

ReplayKit Broadcast upload extension - Service not found

I'm working on an IOS swift application that will allow the user to record the entire screen, any app and even the home screen.
In order to do that, I added a Broadcast Upload Extension to my app.
First I used the RPSystemBroadcastPickerView class in order to add a record button to my view that allow the user to open the record popup and select to which app he wants to broadcast the screen flow. And it's working fine :
But I would like to avoid this step and directly open the popup when the app launch.
So I wrote the following code to do that :
RPBroadcastActivityViewController.load(withPreferredExtension: "ch.jroueche.RecordApp.TestScreen", handler: {broadcastAVC,error in
guard error == nil else {
print("Cannot load Broadcast Activity View Controller.")
return
}
if let broadcastAVC = broadcastAVC {
broadcastAVC.delegate = self
self.present(broadcastAVC, animated: true, completion: {
// broadcastactivityviewcontroller will perform the callback when the broadcast starts (or fails)
print("I've START")
})
}
})
Unlikeenter code here the RPSystemBroadcastPickerView solution, I'm getting the following error :
The preferred broadcast service could not be found.
My issue is similar to the following post :
App not showing up as a broadcast service in RPBroadcastActivityViewController
I also added the extension and the preferred extension identifier is correct.
Why would it be possible using the RPSystemBroadcastPickerView and not programmatically using RPBroadcastActivityViewControllerclass. That does not make sense for me.
Does someone have an idea of what could be the issue and how could I fix it ? Or a workaround in order to do this screen record.
Thanks in advance
It appears that RPBroadcastActivityViewController shows ONLY Broadcast Setup UI Extension, while RPSystemBroadcastPickerView shows ONLY Broadcast Upload Extension. But I have no idea why, as both of them are stated to show list of available providers/services.
It would be very helpful if someone could bring more details on the topic.

App not showing in external display extension for any iPhone

I created a new app in Xcode and added the following code in the AppDelegate file
func updateCarWindow()
{
guard let screen = UIScreen.screens.first(where: { $0.traitCollection.userInterfaceIdiom == .carPlay })
else
{
// CarPlay is not connected
self.carWindow = nil;
return
}
// CarPlay is connected
let carWindow = UIWindow(frame: screen.bounds)
carWindow.screen = screen
carWindow.makeKeyAndVisible()
carWindow.rootViewController = CarViewController(nibName: nil, bundle: nil)
self.carWindow = carWindow
}
and called the function in function application. The app is not showing in the CarPlay external display.
You don’t have direct access to the carplay screen, carplay manages everything using the CPInterfaceController class that is able to display so called templates (such as CPListTemplate and a handful of others). Your ability to draw on the screen is pretty much limited to drawing maps in a CPMapContentWindow.
I recommend you read the Apple docs first starting here:
https://developer.apple.com/carplay/documentation/CarPlay-Navigation-App-Programming-Guide.pdf
Don’t forget to set the correct app permissions and carplay entitlements othereise it simply won’t work and it might not tell you why.
And a final word that the Carplay framework is only supposed to work with navigation apps. Everything else would require a lot of workarounds, not to mention it would never pass app review.
Hope this helps

How to implement Login module as part of my iOS framework

I am building an iOS framework and it should provide some common module like Register, Forgot Password, Login and Profile etc. So, any application that imports my framework should able to use these screens as it is. The challenge that I am facing is navigating from one screen to another screen in my iOS framework code. When navigating from once screen Login(screen1) to another screen Forgot Password(screen2), the handler(callback) methods are being invoked in screen1 view controller instead of screen2 view controller. We tried using xib and storyboard, however I did not find a solution for this.
Can somebody please point out any example code which does the similar stuff ?
Am I missing some thing over here in understanding iOS concepts, I am building an iOS framework which includes some UI flows, Is it possible?
I would suggest a delegate pattern, because callbacks are more one-shot, while delegates serve better the purpose to continually assist the lifetime of an object. Anyway I've created an example to cope with your requirements, git it here (Framework + test app included)
It involves a LoginController, which is the main entry point and orchestra for the framework.
When you initialise it, you pass a callback which will be used to send events, including "forgot password" and "user wants to exit", those are defined in an enum.
public enum LoginFrameworkStatus {
case Login
case ForgotPassword
case Help
case Disaster
case Exited
case UserWantsExit
}
Class offer an entry point to start the process:
public func enterLoginWorkflow(on controller: UIViewController, callback: LoginFrameworkCallback) {
let myBundle = Bundle(for: LoginController.self)
if let navi = UIStoryboard(name: "LoginWorkflow", bundle: myBundle).instantiateInitialViewController() as? MySpecialNavigationController {
presentingController = controller
navi.loginController = self
self.callback = callback
controller.present(navi, animated: true, completion: {
//presented!
callback?( .Login, navi, self) //If reference to LoginController is lost, tell the callback there's a problem.. shouldn't happend because we have a strong reference on the navigation controller.
})
}
}
.. and an exit point:
public func leaveLoginWorkflow() {
presentingController?.dismiss(animated: true, completion: {
self.callback?(.Exited, nil,self)
})
}
So the main interface for your framework would be:
LoginController().enterLoginWorkflow(on: self) { (status, controller, loginController) in
print("\(status) in \(controller?.description ?? "No Controller")")
switch status {
case .UserWantsExit:
loginController?.leaveLoginWorkflow()
case .ForgotPassword:
loginController?.leaveLoginWorkflow()
default:
()
}
}
In the test app I included a minimum workflow for you to test.
Let me know if this is what you needed, or if you want to investigate the delegation pattern, which I think would be way more suitable for this.
Try 1) IcaliaLabs/LoginKit (https://github.com/IcaliaLabs/LoginKit). LoginKit is a quick and easy way to add a Login/Signup UX to your iOS app.
2) TigerWolf/LoginKit https://github.com/TigerWolf/LoginKit
We can create a framework just like Parse.com does. It's well known and great app that used by thousands of developers.
Refer https://github.com/parse-community/ParseUI-iOS

Messenger not appearing in Share Sheet (UIActivityViewController) of branch.io

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.

Resources