Flutter集成Supabase:安卓端密码重置功能失效问题咨询
安卓端Supabase密码重置问题解决方案
1. 安卓端正确的重定向URL格式
你当前使用的com.eis.goodday是不完整的深度链接格式,系统无法正确识别并唤起APP。正确的重定向URL需要是带scheme和路径的完整URI,示例如下:
com.eis.goodday://auth/reset-password
同时需要对应调整AndroidManifest.xml中的intent-filter,确保能匹配这个URI:
<intent-filter android:autoVerify="true"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="com.eis.goodday" android:pathPrefix="/auth/reset-password" /> </intent-filter>
修改后,重置密码的调用代码应更新为:
await Supabase.instance.client.auth.resetPasswordForEmail( anEmail, redirectTo: kIsWeb ? 'https://eisgd.com' : 'com.eis.goodday://auth/reset-password' );
这样点击邮件内的链接时,系统会识别该URI属于你的应用,直接唤起APP而非打开浏览器。
2. 无需深度链接实现密码重置的方式
完全可以绕开深度链接,采用验证码重置的方案:
- 调用
resetPasswordForEmail时不传入redirectTo参数:
await Supabase.instance.client.auth.resetPasswordForEmail(anEmail);
此时Supabase会向用户邮箱发送6位重置验证码,而非跳转链接。
- 在APP内新增一个验证页面,让用户输入收到的验证码和新密码,再调用以下方法完成重置:
await Supabase.instance.client.auth.confirmPasswordReset( token: '用户输入的验证码', password: '用户设置的新密码' );
这种方式全程在APP内完成,无需配置深度链接,彻底避免浏览器跳转问题。
内容的提问来源于stack exchange,提问作者Davout
相关产品推荐
相关产品推荐

