iOS twitter login when app is not installed - ios

In my iOS app I'm using TwitterKit
The problem I have faced is that when twitter app is not installed there is no way to log in user
I saw answers that suggesting adding any callback URL but that doesn't work anymore
I have tried 2 things: search in their docs and found nothing. tried this answer Tweeting using Twitterkit fails when Twitter app is not installed in iOS 11. This solution doesn't work anymore
Thanks for any help!

Add callback URL in this format
twitter-twitterid://
(Replace "twitterid" with "your twitter app id")

After lot of R&D I got the success. Twitter has made call back url compulsory. I found from this link
You need to add twitterkit-123456478:// (twitterkit-consumerKey) in call back url at twitter dashboard setting.
I used this method for opening safari (make sure you add safari framework)
TWTRTwitter.sharedInstance().logIn(with: self) { (session, error) in
if (session != nil) {
print("signed in as \(session?.userName ?? "")");
} else {
print("error: \(error?.localizedDescription ?? "")");
}
}
Appdelegate
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
if url.scheme?.caseInsensitiveCompare(("twitterkit-" + TwitterKey.consumerKey)) == .orderedSame{
TWTRTwitter.sharedInstance().application(app, open: url, options: options)
}
return true
}

Related

Firebase dynamic link short url returns nil ios

I am facing an issue with Firebase dynamic link. The link is generated from the backend. and it's working perfectly in android. but in iOS when I shared the dynamic link on whatsapp or messages app on iPhone. and tap on the link app is opened. and our following function is called in Appdelegate. and after that firebase function is called with the received URL. and the firebase functions return nil. But when I open that link from the safari app is opened and that same firebase function returns the deeplink URL. I have searched alot but did not find the solution. I am using firebase 7.11 version pods.
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: #escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
if let incomingUrl = userActivity.webpageURL{
print("Incoming URL is \(incomingUrl)")
let linkHandled = DynamicLinks.dynamicLinks().handleUniversalLink(incomingUrl) { (dynamicLink, error) in
// guard error == nil else{
// print("Found an error! \(error!.localizedDescription)")
// return
// }
print("error \(error)")
print("dynamicLink \(dynamicLink)") // It returns nil when app open from whatsapp or any 3rd party app.
}
if linkHandled{
return true
}else{
return false
}
}
return false
}
I have also received the following error in both cases.
Error Domain=com.firebase.dynamicLinks Code=403 "(null)" UserInfo={code=403, message=Requests to this API firebasedynamiclinks.googleapis.com method google.firebase.dynamiclinks.v1.DynamicLinksService.GetIosReopenAttribution are blocked., status=PERMISSION_DENIED, details=(
{
"#type" = "type.googleapis.com/google.rpc.ErrorInfo";
domain = "googleapis.com";
metadata = {
consumer = "projects/37866531840";
service = "firebasedynamiclinks.googleapis.com";
};
reason = "API_KEY_SERVICE_BLOCKED";
}
)}
Did you add your custom domains in your info.plist file with FirebaseDynamicLinksCustomDomains parameter like image below.
Have you set AppBundle id as deepLinkURLScheme as like below in AppDelegate class under function didFinishLaunchingWithOptions
let kAppBundleID = Bundle.main.bundleIdentifier
FirebaseOptions.defaultOptions()?.deepLinkURLScheme = kAppBundleID
Please try with this.
Reference:
https://firebase.google.com/docs/dynamic-links/ios/create
By default, Dynamic Links uses your app's bundle identifier as the URL scheme needed to open up your application. We recommend staying with this default value to keep your implementation simple.

branch io clicked_branch_link is false

I have integrated branch.io deep linking in my iOS app (Swift 4.2). What I want is canonical_url when user taps on branch.io short link.
When app is running in background I get all required parameters in following block. but when app is not running and try to tap branch.io short link then app launches but I do not get required parameters even clicked_branch_link is false.
Branch.getInstance().initSession(launchOptions: launchOptions)
{ (params, error) in
print(params as? [String: AnyObject] ?? {})
guard error == nil else { return }
guard let userDidClick = params?["+clicked_branch_link"] as? Bool else { return }
}
Please make sure you have all the basic implementation code as shown in our docs here: https://branchmetrics.github.io/docs/pages/apps/ios/#initialize-branch.
In addition, you can find a working implementation of the Swift Branch SDK in our Testbed application here: https://github.com/BranchMetrics/ios-branch-deep-linking/tree/master/Branch-TestBed-Swift.

Get parameters from URL while not launching app for the first time in viewWillAppear

we provide some parameters using URL schema and it works well if we launch app for the first time. I have provided a custom initialization in AppDelegate:
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if let token = Helper.getQueryStringParameter(url: url.absoluteString, param: AUTH_TOKEN_PARAM) {
tokenFromURL = token
return true
} else {
}
return false
}
However this code does not work if for instance user downloads app, opens it and returns back to the web and presses same button to launch app.
I think I need to check if URL was provided in the viewWillAppear, am I right? How to do that, please help?

iOS App Delegate params dictionary doesn't contain any relevant links

I've added the Branch.io SDK to my iOS project. I have a custom URL scheme which works fine, I've added universal app links which work fine.
Now, I've enabled in my Dashboard the iOS app where I've added my custom URL scheme, custom URL for downloading the app, the App Prefix and the bundle identifier.
In the 'quick links' section I've created a quick link witch has a ["key": "value"] pair for the deep link section and added a redirect again to my jenkins where the ipa can be downloaded.
Now, if I access that link by copy/pasting in mobile safari, without the app installed i'm correctly taken to Jenkins.
At this point I run the app from xcode, and in app delegate I have
branch = Branch.getInstance()
branch.initSession(launchOptions: launchOptions, andRegisterDeepLinkHandler: {params, error in
if error == nil {
// params are the deep linked params associated with the link that the user clicked -> was re-directed to this app
// params will be empty if no data found
// ... insert custom logic here ...
print("params: %#", params as? [String: AnyObject] ?? {})
} else {
print(error?.localizedDescription ?? "")
}
})
The issue is here that params always only contains two params:
params: %# ["+clicked_branch_link": 0, "+is_first_session": 0]
I've also implemented
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
let branchHandled = branch.application(application,
open: url,
sourceApplication: sourceApplication,
annotation: annotation
)
if (!branchHandled) {
// If not handled by Branch, do other deep link routing for the Facebook SDK, Pinterest SDK, etc
var handled = false
handled = //this is Facebook handling
guard handled == false else { return true }
} else {
// do some stuff if it's coming from branch
}
return branchHandled
}
My interest is for branch to pass my ["key": "value"] pair in order to have it handled like a deep link at this point, but I don't know what else to try.
The failure of deferred deep-linking could be due to mismatch of Branch key and Branch link for a particular Branch app. Verify the Branch link used for deferred deep-linking is generated using the same Branch key which is used in info.plist of the iOS project.

How to enable "Install" or "Open" Button in facebook messenger in a "yet-to-launch" ios App for Testing

I have an iOS app under development [Not yet launched]
And i want to get the following "Open" button visible on it while sharing the "from my app" via facebook messenger using FBSDKMessengerSharer:
Facebook SDK
What i have done is the following:
As per Facebook's guidelines for Optimized integration.
https://developers.facebook.com/docs/messenger/ios#optimized_integration
I have put .plist entries for facebook app ids, my own app id, URL schemes etc.
i confirm the when i type my scheme://, it open up my app.
Facebook developer console on developer.facebook.com has correct entries for the app/bundle.
I have added myself and another user as test users as per the guidelines and Facebook have clearly written this is testable without submitting the app.
And then i have the following pieces of code for sharing in the app:
func Share(){
let image : UIImage = UIImage(named: "Sample")!
let opts : FBSDKMessengerShareOptions = FBSDKMessengerShareOptions()
opts.contextOverride = cContext
FBSDKMessengerSharer.shareImage(image, withOptions: opts)
}
And the following for enabling optimized sharing in AppDelegate:
func application(app: UIApplication,
openURL url: NSURL,
options: [String : AnyObject]) -> Bool {
print("Called OpenURL")
let h = FBSDKMessengerURLHandler()
let a = "com.appcompany-new.name"
if h.canOpenURL(NSURL(string: "temp://abc.xyz"), sourceApplication: a) {
h.openURL(NSURL(string: "temp://abc.xyz"), sourceApplication: a)
}
return true
}
func messengerURLHandler(messengerURLHandler : FBSDKMessengerURLHandler,didHandleOpenFromComposerWithContext context : FBSDKMessengerURLHandlerOpenFromComposerContext) {
cContext = context
print("Called Open from composer")
}
I donot see any button, the Open, Install or Reply button even now. What am i missing?

Resources