Not Able To Implement Google Sign In for iOS App - ios

I am following all steps as per this link Click here
After doing all steps it gives me
Can anyone tell me this strange is happening ?
Answer would be appreciated.
Thanks.

Try those:
Add GIDSignIn library header properly, if in case you missing something.
Add AppDelgate.h file into your ViewController (If you not writing this code in AppDelegate.m)
Read point 4 which I copied from GitHub forum, which can be the main reason of your errors.
It looks like iOS 9 changed the constant UIApplicationLaunchOptionsSourceApplicationKey to UIApplicationOpenURLOptionsSourceApplicationKey. Dynamically support both, especially in Xcode 6.4 which doesn't recognize UIApplicationOpenURLOptionsSourceApplicationKey.
After try these all if its still not working then comment here for further help.

This is the AppDelegate.m file from which I implemented Google Signin SDK (the new one)
#define kGoogleClientID #""
#import "AppDelegate.h"
#import <GoogleSignIn/GoogleSignIn.h>
#interface AppDelegate ()<GIDSignInDelegate>
#end
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GIDSignIn sharedInstance].clientID = kGoogleClientID;
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
}
- (void)applicationWillTerminate:(UIApplication *)application {
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
if(annotation){
NSDictionary *options = #{UIApplicationOpenURLOptionsSourceApplicationKey: sourceApplication,
UIApplicationOpenURLOptionsAnnotationKey: annotation};
return [self application:application
openURL:url
options:options];
}
}
/* Google */
- (void)signIn:(GIDSignIn *)signIn
didSignInForUser:(GIDGoogleUser *)user
withError:(NSError *)error {
// Perform any operations on signed in user here.
// ...
}
- (void)signIn:(GIDSignIn *)signIn
didDisconnectWithUser:(GIDGoogleUser *)user
withError:(NSError *)error {
// Perform any operations when the user disconnects from app here.
// ...
}
#end
Hope this helps you out

Related

iOS Universal link not working in background state

In react native the iOS Universal links are working perfectly when the app is in kill/quiet state I tested it with safari but when the app is in background state it only opens the app not working in background state my listener is not working.
Linking.addEventListener('url', async (link) => {
console.log('Linking-addEventListener-link', link);
})
Please check this method is added or not into AppDelegate.m file.
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity
restorationHandler:(nonnull void (^) (NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
{
return [RCTLinkingManager application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler];
}
For everyone having the same issue, just make sure that
#import <React/RCTLinkingManager.h> is just at the top of the imports, do not add it inside any #if #endif import condition.
also add
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
return [RCTLinkingManager application:application openURL:url options:options];
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity
restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
{
return [RCTLinkingManager application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler];
}
just before the last #end inside the #implementation AppDelegate, hope it might help someone.

RN app result in "Native module cannot be null" after updating Expokit from 28 to 32

I am following the documents expokit 32 AppDelegate to upgrade expo v28 to v32 and its detached branch.
I finally got everything working on my non-detached branch on my RN app. Now I am trying to upgrade the detached branch but the following error struck me.
Current set:
- "react-native": sdk-32.0.0.tar.gz from expo
- "expo": "^32.0.0",
- expo-cli --version 2.11.6
- xcode 10.1
- firebase
- "babel-preset-expo": "^5.0.0",
- "react-native-firebase": "^5.0.0",
- "aws-amplify": "^1.1.19",
The problem is that I don't even understand this error let alone how to handle it(there is nothing else print in the console from expo-cli). It points me to some files inside expo npm modules, ./node_modules/expo/tools/hashAssetFiles.js. which doesn`t make any sense to me :((
Maybe something wrong with my AppDelegate.m?
here is mine
// Copyright 2015-present 650 Industries. All rights reserved.
#import "AppDelegate.h"
#import "Firebase.h"
#import "RNFirebaseNotifications.h"
#import "RNFirebaseMessaging.h"
#implementation AppDelegate
static NSString *const CUSTOM_URL_SCHEME = #"higuApp";
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
[RNFirebaseNotifications configure];
[application registerForRemoteNotifications];
application.applicationIconBadgeNumber = 0;
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[super applicationWillEnterForeground:application];
}
#pragma mark - Background Fetch
- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
[super application:application performFetchWithCompletionHandler:completionHandler];
}
#pragma mark - Handling URLs
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
return [super application:app openURL:url options:options];
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
{
return [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
}
#pragma mark - Notifications
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)token
{
[super application:application didRegisterForRemoteNotificationsWithDeviceToken:token];
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)err
{
[super application:application didFailToRegisterForRemoteNotificationsWithError:err];
}
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
[[RNFirebaseMessaging instance] didRegisterUserNotificationSettings:notificationSettings];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler
{
[[RNFirebaseNotifications instance] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
[super application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
#end
Any suggestion is welcomed.
I have tried to comment out everything in App.js and return just null, but the problem persists.
Google lead me to some similar cases which are caused by push notification, but that doesnt see to be my problem.
I tried comment out the codes in AppDelegate.m and doesnt help with the situation.

Why its not showing anything when i open the app with url?

I have following setup, when i open my app (app number 2 open by app number 1 using url) using url in iPhone 7, then i am not getting any url inputs.
its not showing any alert box at all.
How do i check if i am receiving the url input in my app at all or not?
AppDelegate.m:
#import "AppDelegate.h"
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
return YES;
}
ViewController.m:
-(BOOL) application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
//if (url != nil && [url isFileURL]) {
//[self.ViewController handleOpenURL:url];
//}
id test = (NSURL *) url;
UIAlertController * alert= [UIAlertController
alertControllerWithTitle:#"My Title"
message:test
preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alert animated:YES completion:nil];
//NSLog(#">>> got <<< >>> <<< !!!! >>>> : %#", url);
return YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
}
The problem is that
-(BOOL) application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
... is a UIApplicationDelegate method. So it can't be located in ViewController.m. It needs to be in AppDelegate.m.

iOS Facebook SDK 4 FBSDKShareDialog

I have some trouble when I try to implement FBSDKShareDialog to perform facebook sharing via my app. If official fb app is installed it shows blank dialog (where user allows to type some text etc). If user doesn't have fb app it shows correct info but FBSDKSharingDelegate methods doesn't work. (It doesn't work even when user has fb application)
- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results
{
NSLog(#"complete");
}
- (void)sharerDidCancel:(id<FBSDKSharing>)sharer
{
NSLog(#"did cancel");
}
- (void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error
{
NSLog(#"%#", error);
}
It's never called even when I cancel or share via FB application.
My code is:
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentTitle = _place.title;
content.imageURL = [NSURL URLWithString:_place.logoUrl];
content.contentDescription = _place.info;
[FBSDKShareDialog showFromViewController:_viewController withContent:content delegate:self];
I have a delegate inside #interface declaration.
#interface FacebookHandler () < FBSDKSharingDelegate >
#end
My app delegate has
#import <FBSDKCoreKit/FBSDKCoreKit.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
return [[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppEvents activateApp];
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
Where I was wrong? And is it good idea to post some image and title via FBSDKShareLinkContent. Thanks in advance.
Are you calling [FBSDKShareAPI shareWithContent:content delegate:self] from the main thread?
I've already fixed this issue. The problem was that I've delegate to file inherited from NSObject, which can't be a delegate

How to setup Facebook iOS SDK properly with Parse in AppDelegate?

I'm trying to integrate Facebook to my Parse project, but I have problems with the new SDK version.
With the older versions I've just imported the related header files into my AppDelegate, pasted two methods and it worked well.
This is how I've done it:
// AppDelegate.m
#import <Parse/Parse.h>
#import <ParseFacebookUtils/PFFacebookUtils.h>
#import <FacebookSDK/FacebookSDK.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[Parse setApplicationId:#"xy"
clientKey:#"xy"];
[PFFacebookUtils initializeFacebook];
[PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];
return YES;
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [FBAppCall handleOpenURL:url
sourceApplication:sourceApplication
withSession:[PFFacebookUtils session]];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBAppCall handleDidBecomeActiveWithSession:[PFFacebookUtils session]];
}
But now the Facebook SDK contains several frameworks and it's not so clear which one is needed or not. Actually I'm trying the below code, but getting this error: Use of undeclared identifier 'PFFacebookUtils'.
// AppDelegate.m
#import <Parse/Parse.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[Parse setApplicationId:#"xy"
clientKey:#"xy"];
[PFFacebookUtils initializeFacebook];
[PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];
return YES;
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppEvents activateApp];
}
I would really appreciate if somebody could show me his own Fb sdk setup in the AppDelegate with Parse or explain me what did I wrong.
Here I share how I've integrated FB to my project with Parse.
AppDelegate.m
#import <ParseFacebookUtils/PFFacebookUtils.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
...
[PFFacebookUtils initializeFacebook]; // don't forget this. it's not mentioned in tutorial
...
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [FBAppCall handleOpenURL:url
sourceApplication:sourceApplication
withSession:[PFFacebookUtils session]];
}
- (void)applicationWillTerminate:(UIApplication *)application {
[[PFFacebookUtils session] close];
}
Hope this helps.

Resources