{"id":24979915,"url":"https://github.com/mojoauth/ios-sdk","last_synced_at":"2025-03-29T09:45:09.359Z","repository":{"id":253547164,"uuid":"821272635","full_name":"MojoAuth/ios-sdk","owner":"MojoAuth","description":"Integrate MojoAuth into your iOS App with ease. Our iOS SDK provides seamless support for advanced authentication features such as PassKeys, SMS, OIDC, SAML, Social Sign-In, MFA, FIDO, OTP, and passwordless login. Experience top-tier security and performance with our API-first solution.","archived":false,"fork":false,"pushed_at":"2024-06-28T07:18:51.000Z","size":254,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-06T10:18:19.612Z","etag":null,"topics":["authentication","authentication-backend","ios","ios-library"],"latest_commit_sha":null,"homepage":"https://mojoauth.com/docs/","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MojoAuth.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-28T07:16:57.000Z","updated_at":"2025-01-25T04:24:33.000Z","dependencies_parsed_at":"2024-08-17T16:22:51.959Z","dependency_job_id":"d4b2be0c-266c-40b2-8208-cb0d341a6406","html_url":"https://github.com/MojoAuth/ios-sdk","commit_stats":null,"previous_names":["mojoauth/ios-sdk"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MojoAuth%2Fios-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MojoAuth%2Fios-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MojoAuth%2Fios-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MojoAuth%2Fios-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MojoAuth","download_url":"https://codeload.github.com/MojoAuth/ios-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246168087,"owners_count":20734389,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","authentication-backend","ios","ios-library"],"created_at":"2025-02-04T04:15:46.356Z","updated_at":"2025-03-29T09:45:09.336Z","avatar_url":"https://github.com/MojoAuth.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MojoAuth iOS SDK\n\n\n## Introduction ##\nMojoAuth helps to Create a passwordless authentication system for any organization, where they can use our APIs to provide seamless auth experiences and reduce security risks for their customer.\n\n\nMojoAuth helps businesses boost user engagement on their web/mobile platform, manage online identities, utilize social media for marketing, capture accurate consumer data, and get unique social insight into their customer base.\n\nPlease visit [here](https://mojoauth.com/) for more information.\n\n## Documentation\nFor full documentation visit [here](https://mojoauth.com/docs/)\n\n## Author\n\n[MojoAuth](https://www.mojoauth.com/)\n\n## License\n\nThis project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.\n\n\n#### There are three projects in the library:\n\na. SwiftDemo - This is the demo application in Swift(Supported Swift version 5).\u003cbr\u003e\nb. MojoAuthSDK -This is the MojoAuth SDK.\n\n\n## Installing SDK\n\nWe recommend using CocoaPods for installing the library in a project.\n\nCocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:\n\n\n```\n$ gem install cocoapods\n```\n\n### Podfile\n\nOpen a terminal window and navigate to the location of the Xcode project for your application. If you have not already created a Podfile for your application, create one now:\n\n\n```\n$ pod init\n```\n\nTo integrate MojoAuthSDK into your Xcode project using CocoaPods, specify it in your Podfile:\n\n\n```\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '11.0'\n\ntarget 'TargetName' do\n\n#Comment the next line if you don't want to use dynamic frameworks\nuse_frameworks!\npod 'MojoAuthSDK', '~\u003e 1.0.0'\nend\n\n```\n\nThen, run the following command:\n\n\n```\n$ pod install\n\n```\n\n## Initialize SDK\n\n*Create a new File MojoAuth.plist and add it to your App*\n\nAdd the MojoAuth *apiKey* with type *String*\n\n```apiKey  = \u003cMojoAuth API Key\u003e```\n\n\n*After that Import the module in your source code.*\n\n\n```\nimport MojoAuthSDK\n\n```\n\n*Application is launched*\n\n\n```\nimport MojoAuthSDK\n ...\n\n\n@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {\n\n\n...\n\nfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions:[UIApplicationLaunchOptionsKey: Any]?) -\u003e Bool {\n\n            let sdk:MojoAuthSDK = MojoAuthSDK.instance();\n            sdk.applicationLaunched(options: launchOptions);\n\n            //Your code\n\n            return true\n }\n\n...\n\n}\n```\n\n*Application is asked to open URL*\n\nCall this to handle URL's for social login to work properly in your AppDelegate.m\n\n\n```\n@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {\n...\n\nfunc application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -\u003e Bool {\nreturn MojoAuthSDK.sharedInstance().application(app, open: url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplicationOpenURLOptionsKey.annotation])\n}\n...\n\n}\n...\n}\n\n```\n\n## MojoAuth SDK API Methods\n\n\n### Send magic link on the email\n\nThis endpoint sends a magiclink to your email.\n\n```\n    func MagicLink()\n        {\n        \n        AuthenticationAPI.authInstance().sendMagicLink(withEmail: \"email\", language: \"language\", redirect_url: \"url\", completionHandler: {(response,error)in\n            if let e = error{\n                print(e.localizedDescription)\n            }else{\n                print(\"Successfull in sending magic link.\")\n            }\n            })\n    }\n```\n    \n## Check Authentication status\n\nThis endpoint checks the login status of user.\n    \n```\n    func CheckAuthenticationStatus()\n        {\n        \n        AuthenticationAPI.authInstance().checkAuthenticationStatus(withStateID: \"id\", language: \"language\", redirect_url: \"url\", completionHandler: {(response,error)in\n            if let err = error{\n                print(err.localizedDescription)\n            }else{\n                print(\"Sucess\")\n            }\n        })\n    }\n```\n    \n## Resend magic link\n\nThis endpoint resends a magiclink to your email.\n    \n```\n func ResendMagicLink() \n        {\n        AuthenticationAPI.authInstance().resendMagicLink(withStateID: \"id\", language: \"language\", redirect_url: \"url\", completionHandler: {(response,error)in\n            if let e = error{\n                print(e.localizedDescription)\n            }else{\n                print(\"Success in resending magic link.\")\n            }\n        })\n    }\n    \n```\n\n## Send Email OTP\n\nThis endpoint sends Email OTP on the mentioned Email Address.\n    \n```\n    func SendEmailOtp()\n        {\n        AuthenticationAPI.authInstance().sendEmailOTP(withEmail: \"email\", language: \"language\", completionHandler: {(response,error)\n            in\n                if let e = error{\n                    print(e.localizedDescription)\n                }else{\n                    print(\"Success\")\n                }\n        })\n    }\n```\n\n## Verify Email OTP\n\nThis endpoint Verify OTP and returns user response and access token\n\n```\nfunc VerifyEmailOtp()\n    {\n        \n        AuthenticationAPI.authInstance().verifyEmailOTP(withStateID: \"stateId\", otp: \"Otp\", completionHandler: {(response,error)in\n                if let e = error{\n                    print(e.localizedDescription)\n                }else{\n                    print(\"Success\")\n                }\n        })\n        \n    }\n```\n    \n## Resend Email OTP\n\nThis endpoint resends an OTP to your email.\n    \n```\n    func ResendEmailOtp()\n        {\n        \n        AuthenticationAPI.authInstance().resendEmailOTP(withStateID: \"stateId\", language: \"language\", completionHandler: {(response,error) in\n                if let e = error{\n                    print(e.localizedDescription)\n                }else{\n                    print(\"Success\")\n                }\n        })\n    }\n    \n ```   \n \n## Send Phone OTP\n\nThis endpoint sends Phone OTP on the mentioned Phone Number.\n    \n```\n  func SendPhoneOtp()\n      {\n        \n        AuthenticationAPI.authInstance().sendPhoneOTP(withPhone: \"phoneNo.\", language: \"language\", completionHandler: {(response,error) in\n                if let e = error{\n                    print(e.localizedDescription)\n                }else{\n                    print(\"Success\")\n                }\n        })\n    }\n      \n```\n\n \n## Verify Phone OTP\n\nThis endpoint verify Phone OTP on the mentioned Phone Number.\n   \n```\nfunc VerifyPhoneOTP()\n    {\n        \n        AuthenticationAPI.authInstance().verifyPhoneOTP(withStateID: \"id\", otp: \"otp\", completionHandler: {(response,error) in\n                if let e = error{\n                    print(e.localizedDescription)\n                }else{\n                    print(\"Success\")\n                }\n        })\n      \n    }\n```\n\n## Resend Phone OTP\nThis endpoint resends an OTP to your phone Number.\n   \n```\n   func ResendPhoneOtp()\n       {\n        \n        AuthenticationAPI.authInstance().resendPhoneOTP(withStateID: \"id\", language: \"language\", completionHandler: {(response,error) in\n                if let e = error{\n                    print(e.localizedDescription)\n                }else{\n                    print(\"Success\")\n                }\n        })\n    }\n     \n```\n\n## JWKS\nThis endpoint provides a valid public key set for the user to validate their tokens\n\n```\nfunc Jwks(){\n        \n        AuthenticationAPI.authInstance().jwks({(response,error)in\n       \n                if let e = error{\n                    print(e.localizedDescription)\n                }else{\n                    print(\"Success\")\n                }\n        })\n\n    }\n\n```\n\n## Validate Token\n\nThis endpoint Validates the JWT Token\n\n```\n    AuthenticationAPI.authInstance().validateToken(\"\u003ctoken\u003e\", completionHandler: {(response, error)in\n        if let err = error {\n            print(err.localizedDescription)\n        } else {\n            print(\"Success\")\n        }\n    })\n```\n\n## Refresh Token\n\nThis endpoint generates a set of new tokens by using refresh token\n\n```\nfunc RefreshToken()\n    {\n        AuthenticationAPI.authInstance().refreshAccessToken(withRefreshToken: \"token\", completionHandler: {(response, error)in\n            if let err = error {\n                print(err.localizedDescription)\n            }else{\n                print(\"Sucess\")\n            }\n        })\n    }\n```\n\n\n## MojoAuth SDK Native Social Login Methods\n\n### Facebook native login\n\nYou don't need to download and integrate the Facebook SDK with your project. It is distributed as a dependency with MojoAuth SDK. Just make sure your Info.plist\n\n*If you are using our demo, then go to our  AppDelegate.swift and set useFacebookNative to true to display our native facebook ui.*\n\nIf you are making your app, then proceed to add these lines of codes.\n\nand you are calling application:openURL:sourceApplication:annotation in your AppDelegate.m.\n\n\n```\n@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {\n\n...\n\nfunc application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -\u003e Bool{\n        return MojoAuthSDK.sharedInstance().application(app, open: url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplicationOpenURLOptionsKey.annotation])\n }\n...\n\n}\n```\n\n*Replace the values with your Facebook App ID and Display name from your App Settings page in Facebook Developer portal(https://developers.facebook.com/)*\n\n\n```\nMojoAuthSocialLoginManager.sharedInstance().nativeFacebookLogin(withPermissions: [\"facebookPermissions\": [\"public_profile\"]], in: self, completionHandler: {( data, error) -\u003e Void in\n\n    if let err = error {\n        print(err.localizedDescription)\n    } else {\n        print(\"Successfully logged in with facebook\")\n    }\n})\n```\n\n### Google native login\n\nGoogle Native Login is done through Google SignIn Library since this is a static library and has problems when you are using CocoaPods with uses_frameworks!, you have to manually install the SDK.\n\nFollow these steps:\n\n1.For Google SignIn, you would need a configuration file GoogleServices-Info.plist. You can generate one following the steps here.\n\n2.Drag the GoogleService-Info.plist file you just downloaded into the root of your Xcode project and add it to all targets.\n\n3.Google SignIn requires a custom URL Scheme to be added to your project. Add it to your Info.plist file.\n\n4.Add Google Sign In by following the https://developers.google.com/identity/sign-in/ios/sign-in\n\n5.If you are using our demo, go to our AppDelegate.swift and set useGoogleNative to true to display our native google ui. Our demo already contain all the necessary code to perform native Google Sign in, you just have to uncomment any instance of /* Google Native SignIn `\u003ccode block\u003e` */\n\n6.If you are making your own app, proceed to add these lines of codes. You can also see our demo to see the native google sign in action!\n\n7.Add Google SignIn Library to your Podfile. pod 'Google/SignIn'\n\n8.Now change your App Delegate's open URL to handle both google native sign in and our default logins.\n\n\n```\nfunc application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -\u003e Bool\n    {\n        var canOpen = false\n        canOpen = (canOpen || GIDSignIn.sharedInstance().handle(url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String, annotation: options[UIApplicationOpenURLOptionsKey.annotation]))\n\n        canOpen = (canOpen || MojoAuthsSDK.sharedInstance().application(app, open: url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplicationOpenURLOptionsKey.annotation]))\n\n        return canOpen\n    }\n```\n\n9.You have to exchange the Google token with MojoAuth Token. Call the following function in the SignIn delegate method after successful sign in.\n\n\n```\nfunc sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {\n\n        if let err = error\n        {\n            print(\"Error: \\(err.localizedDescription)\")\n        }\n        else\n        {\n            let googleToken: String = user.authentication.accessToken\n            let refreshToken: String = user.authentication.refreshToken\n            let clientID: String = user.authentication.clientID\n            if let navVC = self.window?.rootViewController as? UINavigationController,\n            let currentVC = navVC.topViewController\n            {\n            //@param socialAppName  should have unique social app name as a provider in case of multiple social apps for the same provider (eg. google_\u003csocial app name\u003e )\n\n                MojoAuthSocialLoginManager.sharedInstance().convertGoogleToken(googleToken,google_refresh_token:refreshToken, google_client_id:clientID, in:currentVC, completionHandler: {( data ,  error) -\u003e Void in\n                NotificationCenter.default.post(name: Notification.Name(\"userAuthenticatedFromNativeGoogle\"), object: nil, userInfo: [\"data\":data as Any,\"error\":error as Any])\n                })\n            }\n        }\n    }\n```\n\n10.As the final step, add the google native signOut on your logout button.\n\n\n```\nGIDSignIn.sharedInstance().signOut()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmojoauth%2Fios-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmojoauth%2Fios-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmojoauth%2Fios-sdk/lists"}