Linkedin SDK issue in ios - ios

i am using Linkedin SDK in ios.
i am using following code to authenticate the user
[LISDKSessionManager createSessionWithAuth:[NSArray arrayWithObjects:LISDK_BASIC_PROFILE_PERMISSION, LISDK_EMAILADDRESS_PERMISSION, nil]
state:nil//#"some state"
showGoToAppStoreDialog:YES
successBlock:^(NSString *returnState) {
}
errorBlock:^(NSError *error) {
}
];
by using this code , i am able to open linkedin app but unable to get callback from linkedin app to my app.
Not Getting call on
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
NSLog(#"%s url=%#","app delegate application openURL called ", [url absoluteString]);
if ([LISDKCallbackHandler shouldHandleUrl:url]) {
return [LISDKCallbackHandler application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
}
return YES;
}
i am using "liMY_APPID" in URL Schemes.And also try from LinkedIn iOS SDK Bundle Suffix
Please help me how i can get callback from linkedin app

Make sure if you are using iOS 9.0 or higher as base SDK since
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
is deprecated from iOS 9. Instead use
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<NSString *,
id> *)options
Use options[UIApplicationLaunchOptionsSourceApplicationKey] and options[UIApplicationLaunchOptionsAnnotationKey] for sourceApplication and annotation respectively.
Example:
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
if ([LISDKCallbackHandler shouldHandleUrl:url]) {
return [LISDKCallbackHandler application:app openURL:url sourceApplication:options[UIApplicationLaunchOptionsSourceApplicationKey] annotation:options[UIApplicationLaunchOptionsAnnotationKey]];
}
return YES;
}

Your code is correct only but your problem is related to URL schemes...
Add the same URL scheme in your info.plist file what you have mentioned in "iOS URL Suffix Schemes" so that once linkedIn will call the same URL scheme, Might be you have used incorrect URL scheme in your app.
URL scheme is nothing but it is a link to open your application. If you enter your URL scheme in mobile safari i.e.
testApp://
it will open your app (If installed). Using following process you can add it in your project
right-click on your info.plist and choose Open As – Source Code:
right-click on your info.plist and select Show Raw Keys/Values, the output will look as follows:
check link for more details to add custom URL schemes

ISSUE RESOLVED
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
if LISDKCallbackHandler.shouldHandle(url) {
LISDKCallbackHandler.application(app, open: url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String, annotation: options[UIApplicationOpenURLOptionsKey.annotation])
}
return true
}

Did you add the LIAppId property to your Info.plist?

Have you added all your bundles to LinkedIn dev's center for iOS? If not, copy your bundle id and add it to https://www.linkedin.com/developer/apps/APP_ID/mobile and do not forget to Save.

Related

Dynamic link always open App Store regardless of App installed or not

I struggled with dynamic links for days. Appreciate any help, please.
I integrate firebase dynamic links, if I paste the link in chrome url and press enter, it can open app with event triggered and url passed
but if I click the open button on the preview page, it always open App store regardless whether the app installed or not
Any thoughts?
I have browsed all posts on the web, but no good luck.
"react-native": "^0.59.5"
"react-native-firebase": "^5.3.1"
pod 'Firebase/Core', '~> 5.20.1'
pod 'Firebase/DynamicLinks', '~> 5.20.1'
Domain on firebase console: https://links.umrgo.com/links
bundle id: com.umrgo.www.umr-app-ios
URL Types identifier: links.umrgo.com
URL Types identifier: com.umrgo.www.umr-app-ios
capabilities: applinks:links.umrgo.com
release build
I also add FirebaseDynamicLinksCustomDomains with a array of string
https://links.umrgo.com
Some of my codes are as below.
[FIROptions defaultOptions].deepLinkURLScheme = #"com.umrgo.www.umr-app-ios";
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
options:(NSDictionary<NSString*, id> *)options
{
BOOL handled = [[RNFirebaseLinks instance]
application:application
openURL:url
options:options
] || [RCTLinkingManager
application:application
openURL:url
options:options
];
return handled;
}
- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray *))restorationHandler {
BOOL handled = [[RNFirebaseLinks instance]
application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler
] || [RCTLinkingManager
application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler
];
return handled;
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
BOOL handled = [RCTLinkingManager
application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation
];
return handled;
}
const link = new firebase.links.DynamicLink(`https://www.umrgo.com/publish/${publishId}?publishType=${publishType}&publishId=${publishId}&otherUserUnionId=${currentUserUnionId}&conversationId=${conversationId}`,
'links.umrgo.com/links').android.setPackageName(conf.GooglePackageName).ios.setBundleId(conf.AppleBundleId).ios.setAppStoreId(conf.AppleAppID);
firebase.links()
.createShortDynamicLink(link, 'UNGUESSABLE')
.then((url) => {
var payload = {
key: createLinkUniqueKey(conversationId, publishId, currentUserUnionId, publishType),
url: url,
publish_id: publishId,
target_user_unionid: currentUserUnionId,
conversation_id: conversationId,
publish_type: publishType
}
axios.post(getApiEndpoint(conf.UMRApiUrls.createDynamicLinkRemote), payload, {
headers: getAuthHeader()
}).then(response => {
console(response)
})
});
Some snapshots are below:
redirect to app store
ask for open app
enter link in browser and press enter
app open with url passed if enter link in browser
bottom right is the app, release build
You mentioned pasting link into a browser. If you do this in Safari, it will intentionally not go directly to your app because the device is assuming that your intent is to open a web page. If you tap on a link, it could act differently. It's possible that Chrome is following this same idea.
This answer provides some good testing steps to make sure it's working right: https://stackoverflow.com/a/44817701/2612222

What is the correct way of connecting Firebase UI and Facebook SDK in AppDelegate?

I want to use both Firebase UI (for signup/login) and Facebook SDK (for sharing/posting) in my React Native app.
Both SDKs want to control the application:(UIApplication *)app openURL:(NSURL *)url handler.
Here's Facebook openURL code and Firebase UI openURL.
What is the correct way to combine the two snippets? I've come up with the code below, but neither SDK explains what URLs do they handle and when, so I'm not sure which one should execute first?
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options {
NSString *sourceApplication = options[UIApplicationOpenURLOptionsSourceApplicationKey];
id annotation = options[UIApplicationOpenURLOptionsAnnotationKey];
BOOL handled = [[FUIAuth defaultAuthUI] handleOpenURL:url sourceApplication:sourceApplication];
if (!handled) {
handled = [[FBSDKApplicationDelegate sharedInstance] application:app
openURL:url
sourceApplication:sourceApplication
annotation:annotation
];
}
return handled;
}

Can I possibly get the parameter in URL Scheme when my app set to not run in background?

I am trying to open my app using URL Scheme with a parameter on it, my problem is, is it possible to get the parameter when the app is set to not run in the background.
SampleApp-info.plist
<key>UIApplicationExitsOnSuspend</key>
<true/>
AppDelegate.m
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation;
{
NSLog(#"url recieved: %#", url);
NSLog(#"scheme: %#", [url scheme]);
NSLog(#"query string: %#", [url query]);
NSLog(#"host: %#", [url host]);
return YES;
}
When UIApplicationExitsOnSuspend is set to true and try to open my app from Safari, it's not creating any logs but when I remove the key it is working well. I have to restart my app to load the first viewcontroller and suspending it on the background is the best way, I think...
Can anyone help me on this? or a better way so I can reload my app starting in the first viewcontroller? Newbie here.
I really appreciate any help. Thank you and regards.
UIApplicationExitsOnSuspend Settings
You have to set UIApplicationExitsOnSuspend to false. URL Scheme Callback will not work with UIApplicationExitsOnSuspend set to true. If you want to have a simular behavior like UIApplicationExitsOnSuspend set to true just add the following code
- (void)applicationDidEnterBackground:(UIApplication *)application {
[super applicationDidEnterBackground:application];
exit(0);
}
First you have to make an entry in in Info.plist
e.g. entry your URL Scheme. In this case (in the picture) the callback will be blurry:// the identifier should be normally unique
Callback Implementation
For Pre iOS 9 swift
optional func application(_ application: UIApplication,
handleOpenURL url: NSURL) -> Bool {
NSLog("URL is %#", url)
return true
}
For Pre iOS 9 objective-c
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
// handler code here
NSLog(#"Url is %#, url);
return YES;
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
// handler code here
NSLog(#"Url is %#, url);
return YES;
}
IOS 9 objective-c
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<NSString *,
id> *)options {
NSLog(#"Url is %#", url);
return YES;
}
IOS 9 - Swift
optional func application(_ app: UIApplication,
openURL url: NSURL,
options options: [String : AnyObject]) -> Bool {
NSLog("URL is", NSURL)
return true
}
Test the callback
Just open the weburl in the example case blurry://test with the mobile safari on your Handy

Google SignIn SFSafariViewController/WebView redirects to Google.com after accepting permissions

Im trying to implement the new Google SignIn Library that I installed using Cocoapods. Deployment Target is 8.4 and Im testing in a 9.0.2 device.
1- I have the proper plist file with clientID and reverseID
2- I have the URL types set
3- I have the AppDelegate as a delegate of GIDSignIn [GIDSignIn sharedInstance].delegate = self; and the proper delegate methods implemented to catch the callback - (void)signIn:(GIDSignIn *)signIn
didSignInForUser:(GIDGoogleUser *)user
withError:(NSError *)error
4- I have the - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{ return [[GIDSignIn sharedInstance] handleURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
5- Im using the automatic GIDSignInButton class and is placed in a subclass of UIViewController, so I dont need to implement the GIDSignIn uiDelegate methods. But I still have [[GIDSignIn sharedInstance] setUiDelegate:self]; set in the viewDidLoad
6- I have SFSafariViewController.framework in the Linked Libraries.
7- I never manually set the clientID to GIDSignIn because that is not part of the instructions at google's official documentation. Although many people keep doing it I dont know why.
The Problem: Once I press the Login button, a SFSafariViewController gets presented, I select the account I want to use (notice it never went out of my app into any other google apps for authentication even though I have several installed). The permissions get presented, I see the name & logo of my app that I configured in Google Developer Console, I accept the permissions. The SFSafariViewController falls back to "www.google.com" and thats it. The only way to dismiss this screen is to tap on the "OK" button in the uppper right corner, and then the - (void)signIn:(GIDSignIn *)signIn
didSignInForUser:(GIDGoogleUser *)user
withError:(NSError *)error gets called, with error saying the used Cancelled the login process.
Just solve it. As you are using CocoaPods, seems like you have to set
Swift:
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
return GIDSignIn.sharedInstance().handleURL(url, sourceApplication: sourceApplication, annotation: annotation)
}
Obj-c
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [[GIDSignIn sharedInstance] handleURL:url sourceApplication:sourceApplication annotation:annotation];
}
in your appDelegate. Now you will be redirected to your app after accepting the permissions.
More info: https://developers.google.com/identity/sign-in/ios/sign-in
I found out the problem. Google Official Documentation mentions the need to implement the following method in your AppDelegate
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [[GIDSignIn sharedInstance] handleURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
But it never mentions the need to implement also a similar method called
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options
I had to implement both methods in order for my app to work properly. I have facebook authentication too, so my methods ended up looking like the following.
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options {
return [[FBSDKApplicationDelegate sharedInstance] application:app
openURL:url
sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
annotation:options[UIApplicationOpenURLOptionsAnnotationKey]]
|| [[GIDSignIn sharedInstance] handleURL:url
sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
annotation:options[UIApplicationOpenURLOptionsSourceApplicationKey]];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation
] ||
[[GIDSignIn sharedInstance] handleURL:url
sourceApplication:sourceApplication
annotation:annotation];
}

Facebook iOS SDK 3.1 does not return to the app after authentication

I'm using Facebook iOS SDK 3.1 and it does not return to my app after authentication. I'm sure the bundle ID has been entered and the login and deep link has been enabled since last night. Anyone know the possible reason or has the same problem?
Thanks,
Make sure you added these two functions. Also check your product name matched your facebook app name. Use 'URL types' in plist.
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
Facebook *fb = [self sharedFacebook];
return [fb handleOpenURL:url];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
Facebook *fb = [self sharedFacebook];
return [fb handleOpenURL:url];
}

Resources