Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Function doesn't work after callback #60

Closed
cokealmonacid opened this issue Feb 28, 2017 · 8 comments
Closed

Function doesn't work after callback #60

cokealmonacid opened this issue Feb 28, 2017 · 8 comments

Comments

@cokealmonacid
Copy link

After give the permissions to twitter and comeback to the app, the app dont do nothing:

twLogin() {
		twitter({
		  appId: XXXXXXX,
		  appSecret: XXXXXXXXXXXX,
		  callback: 'ciudadfacilapp://'
		}).then((info) => {
			console.log('works!')
		}).catch((error) => {
			console.log(error)
		});
	}

call this function through a TouchableHighlight like this:

<TouchableHighlight style={styles.buttonLoginTw} onPress={() => this._twLogin()}>
         <Text style={styles.textLogin2}>Login con Twitter</Text>
</TouchableHighlight>

Any idea?

@adamjmcgrath
Copy link
Owner

Have you followed the instructions on setting up deep links for iOS and Android? https://github.com/adamjmcgrath/react-native-simple-auth#install

@cokealmonacid
Copy link
Author

yes, try it but was thinking, maybe is the sdk of facebook, now i remove all and try to use this repo to login both (twitter and facebook)

@cokealmonacid
Copy link
Author

Cleaned up the project, take away the FBSDK and still doesn't work, i make the setup, put the deep link in iOS and Android, click the login with twitter, give the permissions and comeback to the app but console.log('works!') dont work

@nabeelvalapra
Copy link

Can you show up your AndroidManifest.xml?

@cokealmonacid
Copy link
Author

brrrpp! problem whit the linking in iOS, the problem was solved

@ozsirma
Copy link

ozsirma commented Mar 2, 2017

How did you solve the problem for ios ? can you describe ?

@cokealmonacid
Copy link
Author

This are all the steps that i did from the beginning:

  • Use yarn to add react-native-simple-auth
  • Added the launchMode to my MainActivity of AndroidManifest.xml and added the deep link scheme too, like this:

`

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<uses-sdk
    android:minSdkVersion="16"
    android:targetSdkVersion="22" />

<application
  android:name=".MainApplication"
  android:allowBackup="true"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:theme="@style/AppTheme">
  <activity
    android:name=".MainActivity"
    android:launchMode="singleTask"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="ciudadfacilapp" />
    </intent-filter>
   <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="fb975638039115054" />
    </intent-filter>
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
  <service android:name="com.mapbox.mapboxsdk.telemetry.TelemetryService"/>
</application>

`

*If you see, i added the intent-filter for Twitter (ciudadfacilapp) and Facebook (fb975638039115054)

  • Now on iOS added the next to my info.plist to add the deep link:

<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLSchemes</key> <array> <string>ciudadfacilapp</string> </array> </dict> <dict> <key>CFBundleURLSchemes</key> <array> <string>fb975638039115054</string> </array> </dict> </array>
Now if you see there is a CFBundleURLSchemes for ciudadfacilapp (twitter) and for fb975638039115054.

This is my AppDelegate.m :
`#import <React/RCTLinkingManager.h>

@implementation AppDelegate

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    NSURL *jsCodeLocation;

    jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

    RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
    moduleName:@"CiudadFacilApp"
    initialProperties:nil
    launchOptions:launchOptions];
    rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    UIViewController *rootViewController = [UIViewController new];
    rootViewController.view = rootView;
    self.window.rootViewController = rootViewController;
    [self.window makeKeyAndVisible];
    return YES;
    }

  • (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
    sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
    {
    return [RCTLinkingManager application:application openURL:url
    sourceApplication:sourceApplication annotation:annotation];
    }

// Only if your app is using Universal Links.

  • (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity
    restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
    {
    return [RCTLinkingManager application:application
    continueUserActivity:userActivity
    restorationHandler:restorationHandler];
    }

@EnD
`
IMPORTANT NOTE: When you add the RCTlinkingManager.h like a import in your AppDelegate.m and give you a error just change it to <React/RCTLinkingManager.h>m if you dont get this library you can follow the steps described here to added https://facebook.github.io/react-native/docs/linking-libraries-ios.html#manual-linking

Hope this help you!

@ozsirma
Copy link

ozsirma commented Mar 3, 2017

Thank you for your help. It works ! 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants