React-Native三方登录-苹果登录

1、在苹果开发者后台将Sign in with Apple 打开;
React-Native三方登录-苹果登录_第1张图片
开发者网址:https://developer.apple.com

2、在Xcode里面设置一下
React-Native三方登录-苹果登录_第2张图片
3、将一下代码导入IOS项目:
React-Native三方登录-苹果登录_第3张图片
具体代码在GitHub:https://github.com/JonsonHI/SignWithApple(原作者)

4、如上操作,都已经完成则在RN代码,所需位置引入一下模块:

import {  requireNativeComponent} from 'react-native';


//导入封装好的方法
var NativeView = requireNativeComponent('SignWithApple');

5、js代码进行调用:

{Utils.size.os === 'ios' ?
                    
                        
                            {
                                    if(info.nativeEvent.success){
                                        alert(info.nativeEvent.success)
                                    }else if(info.nativeEvent.error){
                                        alert(info.nativeEvent.error)
                                    }
                                }}
                            >
                                    //可换成自己的图
                            
                        
                    
                    :
                    null
                }

6、最终实现效果如下:
React-Native三方登录-苹果登录_第4张图片
React-Native三方登录-苹果登录_第5张图片
7、详细可参考文档:https://www.jianshu.com/p/6dec7972267b

8、作者是个好人,解决了个官方文档没有的大问题哦

你可能感兴趣的:(React,前端,es6,react,native)