Open jorgementx opened 1 month ago
Hi @jorgementx,
thank you for posting the issue and for using the plugin. Can you provide the steps to reproduce the issue? When I checkout the repository and then run
cd ios
pod install
open Plugin.xcworkspace
Then Xcode opens and I can successfully build the iOS project. In Xcode under Signing & Capabilities I have selected my signing certificate.
There is also an automated test (github action) for this repository that compiles the ios code and runs ios tests. It is to make sure that the iOS code compiles and has no errors.
When you run npm run test:ios
then the iOS code is build and the tests are run in a iOS simulator "iPhone 15,OS=17.5". To run the tests make sure the simulator is installed and that under Team, your signing certificate is set as in the screenshot above.
Would like to hear if you can get it to run without code changes and maybe you have suggestions for improvement.
Note that to use the plugin in your ionic project, you do not need to compile the iOS project. You can just add the npm package to your project.
Following the steps provided above I still get the error. The only way i can make it to work is by installing/updating pods without this dependency.
Some extra infromation in case it is useful:
If you can think of any other information that migth be useful don't hesitate to ask for it
Can you check if you are using the latest version of the code. In the screenshot below the iOS Plugin name is "Plugin" but in your screenshot it is "CapacitorNativeGoogleOneTapSignin"?
I'm sorry I forgot to respond earlier. After checking the package-lock.json and the node_modules just to make sure, I can confirm I'm currently using the last version of the package (6.1.6). Inside node_modules where your project lives the folder name is Plugin but I'm guessing that after installing in another app the name that is used is the one you set inside the package.json, which is "capacitor-native-google-one-tap-signin".
Edit: After typing all this I realized that you published a new version, should I try with that one?
@jorgementx, can you try the following:
# ensure ionic is installed and up to date
npm install -g @ionic/cli
# create a new ionic project
ionic start testOneTap blank --type=react
# go to the created directory
cd ./testOneTap
# install this plugin
npm i --save capacitor-native-google-one-tap-signin
# add ios support
npm install @capacitor/ios
# build & sync
npm run build
npx cap update
# open xcode
npx cap open ios
Now run the app in xcode to see if it is working.
Then you can edit Home.tsx as floows to check if you get the id token.
import React from 'react';
import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar, IonButton } from '@ionic/react';
import { GoogleOneTapAuth } from 'capacitor-native-google-one-tap-signin';
import './Home.css';
const Home: React.FC = () => {
const clientId = '333448133894-m88bqcrq93ao7vi2j4o475fnlbsnhc9g.apps.googleusercontent.com';
const handleClick = async () => {
void GoogleOneTapAuth.initialize({ clientId: clientId });
// Trigger auto sign-in and if not successful try one-tap sign-in.
let signInResultOption = await GoogleOneTapAuth.tryAutoOrOneTapSignIn();
if (signInResultOption.isSuccess === false) {
// Start the sign-in with button flow.
signInResultOption = await GoogleOneTapAuth.signInWithGoogleButtonFlowForNativePlatform();
}
console.log(signInResultOption);
};
return (
<IonPage>
<IonHeader>
<IonToolbar>
<IonTitle>Home</IonTitle>
</IonToolbar>
</IonHeader>
<IonContent className="ion-padding">
<IonButton onClick={handleClick}>Trigger signInWithGoogleButtonFlowForNativePlatform</IonButton>
</IonContent>
</IonPage>
);
};
export default Home;
# Build and sync
npm run build
npx cap sync
Start the app in xcode to see if you get the idToken displayed (in xcode) if you click the button.
The IOS version has an error in the Swift codebase that gets thrown at compile time:
The solution for me at the moment is using
@codetrix-studio/capacitor-google-auth
just for the IOS version of the app, and everytime I runionic cap build ios
removing the dependency ofcapacitor-native-google-one-tap-signin
by removing the following line from thefrontend/ios/App/Podfile
:and running
pod update
insidefrontend/ios/App
.I know it's not a great solution (but at least gets the job done) and that's why I would like to use just this plugin to handle social auth with google.