{"id":30107113,"url":"https://github.com/walkover-web-solution/msg91-sendotp_swift_sdk","last_synced_at":"2025-08-10T01:33:37.451Z","repository":{"id":302588525,"uuid":"1011015335","full_name":"Walkover-Web-Solution/MSG91-sendOTP_Swift_SDK","owner":"Walkover-Web-Solution","description":"Swift SDK for sending and verifying OTP via SMS, Email, Call \u0026 WhatsApp using MSG91.","archived":false,"fork":false,"pushed_at":"2025-07-03T06:55:48.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-03T07:30:06.766Z","etag":null,"topics":["2fa","email-verification","msg91","otp-verification","sendotp","sms","swift-package","two-factor-authentication"],"latest_commit_sha":null,"homepage":"https://msg91.com/in","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Walkover-Web-Solution.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"zenodo":null}},"created_at":"2025-06-30T07:15:07.000Z","updated_at":"2025-07-03T06:51:59.000Z","dependencies_parsed_at":"2025-07-03T07:32:06.273Z","dependency_job_id":"3431c10f-458a-4cf8-894c-b96d2acff68b","html_url":"https://github.com/Walkover-Web-Solution/MSG91-sendOTP_Swift_SDK","commit_stats":null,"previous_names":["walkover-web-solution/msg91-sendotp_swift_sdk"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Walkover-Web-Solution/MSG91-sendOTP_Swift_SDK","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Walkover-Web-Solution%2FMSG91-sendOTP_Swift_SDK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Walkover-Web-Solution%2FMSG91-sendOTP_Swift_SDK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Walkover-Web-Solution%2FMSG91-sendOTP_Swift_SDK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Walkover-Web-Solution%2FMSG91-sendOTP_Swift_SDK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Walkover-Web-Solution","download_url":"https://codeload.github.com/Walkover-Web-Solution/MSG91-sendOTP_Swift_SDK/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Walkover-Web-Solution%2FMSG91-sendOTP_Swift_SDK/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269663405,"owners_count":24455804,"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","status":"online","status_checked_at":"2025-08-09T02:00:10.424Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["2fa","email-verification","msg91","otp-verification","sendotp","sms","swift-package","two-factor-authentication"],"created_at":"2025-08-10T01:33:35.942Z","updated_at":"2025-08-10T01:33:37.433Z","avatar_url":"https://github.com/Walkover-Web-Solution.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Send OTP Swift Sdk! \n\n![Swift](https://img.shields.io/badge/Swift-5.5%2B-orange?logo=swift)\n![Platform](https://img.shields.io/badge/platform-iOS%20%7C%20macOS-blue)\n![SPM Compatible](https://img.shields.io/badge/SPM-compatible-brightgreen?logo=swift)\n![Version](https://img.shields.io/github/v/release/Walkover-Web-Solution/MSG91-sendOTP_Swift_SDK?release=tag)\n\n\n**The SendOtp SDK makes verifying OTP easy. SDK supports the verification of email and phone numbers via SMS, Calls \u0026 Whatsapp.**\n\n\n\n## Getting started\n\nLogin or create account at MSG91 to use sendOTP services.\n\n**Get your widgetId and authToken:**\n\nAfter login at MSG91, follow below steps to get your widgetId and authToken:\n1. Select OTP option available on dashboard.\n2. Create and configure your widget.\n3. If you are first time user then generate new token and keep it enable.\n4. The widgetId and authToken generated from the above steps will be required for initializing the widget.\n\n**Note:** To ensure that this SDK functions correctly within your mobile application, please enable Mobile Integration while configuring the widget.\n\n## 📦 Installation\n\n### Swift Package Manager (SPM)\n\nYou can install the package via **Xcode**:\n\n1. Open your project in **Xcode**\n2. Go to **File \u003e Add Packages**\n3. Enter the repository URL: https://github.com/Walkover-Web-Solution/MSG91-sendOTP_Swift_SDK\n4. Select the latest version\n5. Click **Add Package**\n\nOr \n\nAdd the package manually to your `Package.swift` file:\n\n```swift\ndependencies: [\n .package(url: \"https://github.com/Walkover-Web-Solution/MSG91-sendOTP_Swift_SDK\", from: \"1.0.0\")\n]\n```\n\n## Example\n\n```jsx\nimport SwiftUI\nimport sendOtp // Importing the custom Swift Package you created\n\nstruct ContentView: View {\n    @State private var number: String = \"\"\n\n    var body: some View {\n        VStack(spacing: 20) {\n            // MARK: - Input Field\n            // User enters the mobile number here\n            TextField(\"Enter number/mail\", text: $number)\n                .padding()\n                .background(Color(.systemGray6))\n                .cornerRadius(8)\n                .padding(.horizontal)\n\n            // MARK: - Send OTP Button\n            Button(action: {\n                handleSendOtp() // Trigger OTP send when tapped\n            }) {\n                Text(\"Send OTP\")\n                    .foregroundColor(.white)\n                    .padding()\n                    .frame(maxWidth: .infinity)\n                    .background(Color.blue)\n                    .cornerRadius(8)\n            }\n            .padding(.horizontal)\n        }\n        .padding()\n        .onAppear {\n            // MARK: - Initialize OTP Widget\n            // This must be called before using OTP methods\n            OTPWidget.initializeWidget(\n                widgetId: \"3461******************38\",\n                tokenAuth: \"125*******************TP1\"\n            )\n        }\n    }\n\n    // MARK: - OTP Sending Logic\n    func handleSendOtp() {\n        let data: [String: Any] = [\n            \"identifier\": number // Pass user-entered number in expected key\n        ]\n\n        // Call the sendOTP function from the Swift Package\n        OTPWidget.sendOTP(body: data) { result in\n            switch result {\n            case .success(let response):\n                // Handle success - You can parse and use `response` as needed\n                print(\"OTP Response: \\(response)\")\n            case .failure(let error):\n                print(\"Error sending OTP: \\(error.localizedDescription)\")\n            }\n        }\n    }\n}\n\n// MARK: - Preview\n#Preview {\n    ContentView()\n}\n```\n\n\n# SDK Methods\n\nWe provide methods, which helps you integrate the OTP verification within your own user interface.\n\n`getWidgetProcess` is an optional method, this will receive the widget configuration data.\n\u003cbr\u003e\n\u003cbr\u003e\n\nThere are three methods `sendOTP`, `retryOTP` and `verifyOTP` for the otp verification process.\n\nYou can call these methods as follow:\n\n### `sendOTP`\n\nThe sendOTP method is used to send an OTP to an identifier. The identifier can be an email or mobile number (it must contain the country code without +).\n\u003cbr\u003e\nYou can call this method on a button press.\n\u003cbr\u003e\n\u003cbr\u003e\n\n```jsx\nlet body: [String: Any] = [\n    \"identifier\": \"91**********\"\n]\n        \nOTPWidget.sendOTP(body: body) { result in\n    switch result {\n    case .success(let response):\n        print(\"OTP Response: \\(response)\")\n    case .failure(let error):\n        print(\"Error: \\(error.localizedDescription)\")\n    }\n}\n```\n**or**\n```jsx\nlet body: [String: Any] = [\n    \"identifier\": \"alpha_do@gmail.com\"\n]\n        \nOTPWidget.sendOTP(body: body) { result in\n    switch result {\n    case .success(let response):\n        print(\"OTP Response: \\(response)\")\n    case .failure(let error):\n        print(\"Error: \\(error.localizedDescription)\")\n    }\n}\n```\n\n### `retryOTP`\n\nThe retryOTP method allows retrying the OTP on desired communication channel.\n\u003cbr\u003e\nretryOTP method takes optional channel code for `'SMS-11'`, `'VOICE-4'`, `'EMAIL-3'`, `'WHATSAPP-12'` for retrying otp.\n\n*Note:* If the widget uses the default configuration, don't pass the channel as argument.\n\n```jsx\nlet retryBody: [String: Any] = [\n    \"reqId\": \"3463***************43931\",\n    \"retryChannel\":\"11\" // Retry channel code (here, SMS:11)\n]\n\nOTPWidget.retryOTP(body: retryBody) { result in\n    switch result {\n    case .success(let response):\n        print(\"Retry Response:\", response)\n    case .failure(let error):\n        print(\"Error:\", error)\n    }\n}\n```\n\n### `verifyOTP`\n\nThe verifyOTP method is used to verify an OTP entered by the user.\n\n```jsx\nlet verifyBody: [String: Any] = [\n    \"reqId\": \"3463***************43931\",\n    \"otp\":\"****\"\n]\n\nOTPWidget.verifyOTP(body: verifyBody) {result in\n    switch result {\n    case .success(let response):\n        print(\"Verify Otp Response:\", response)\n    case .failure(let error):\n        print(\"Error:\", error)\n    }    \n}\n```\n\n\n\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\n## License\n\n```\nCopyright 2022 MSG91\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```@\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalkover-web-solution%2Fmsg91-sendotp_swift_sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwalkover-web-solution%2Fmsg91-sendotp_swift_sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalkover-web-solution%2Fmsg91-sendotp_swift_sdk/lists"}