Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,79 @@ After this, when user want to open the chat, you can simply ask for the UINaviga
```

Note: Kindly go through the swift's documentation for further APIs and appropriately call corresponding methods.


## **Integrate with SwiftUI**

To use the VerloopSDK in SwiftUI apps, we need to use the UIViewControllerRepresentable to represent an UIKit view controller. Let’s go over all the steps required in doing that.

### **Setting up the UIKit view controller**

UIViewControllerRepresentable is a protocol and requires to implement two methods:

makeUIViewController - create and configure the view controller;
updateUIViewControoler - update the state of the view controller.

We are going to create and configure the VerloopSDK in the makeUIViewController method. We don’t need to update it, so we can leave the updateUIViewControoler empty.

### **Coordinator**
Coordinator class that implements the VLEventDelegate protocol. It is a thoughtful approach to how the SwiftUI can communicate with the UIKit delegation pattern idea.

```
import SwiftUI
import VerloopSDK

struct VerifyVerloopRepresentable: UIViewControllerRepresentable {

func makeUIViewController(context: Context) -> some UIViewController {
var mSDK:VerloopSDK?

//Initialise the configuration object `VLConfig`. You could pass an identifier to uniquely indentify a user - `userId`. Will be useful to manage logged in user sessions.
var config = VLConfig(clientId: "tarun")

//config.setRecipeId(recipeId id: String?)
//config.setNotificationToken(notificationToken: string)
//config.setUserName(username name:String)
//config.setUserEmail(userEmail email:String)
//config.setUserPhone(userPhone phone:String)
//config.setUserParam(key:String, value:String)

verloop = VerloopSDK(config: config)
let chatController = verloop!.getNavController()
return chatController
}

func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) { }

}
```

```
let config = VLConfig(clientId: String)

let config = VLConfig(clientId: String, userId: String?) //clientId is required parameter while userId.
```
You could otherwise update the userId using the method `setUserId` on an instance of `VLConfig`.

```
let config = VLConfig(clientId: String)

config.setUserId(userId: String)
```
- Listeners: You could set two listenrs when an end user taps on a button or url in the recipe.
```
//Button Click Listener

Example:

config.setButtonOnClickListener { title, type, payload in
print("button click listenr called")
}

// URL Click Listener

config.setUrlClickListener { title, type, payload in
print("button click listenr called")
}

```
20 changes: 5 additions & 15 deletions VerifyVerloop/VerifyVerloop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1310;
LastUpgradeCheck = 1540;
LastUpgradeCheck = 1310;
TargetAttributes = {
18C7298428166C81006EF202 = {
CreatedOnToolsVersion = 13.1;
Expand Down Expand Up @@ -405,7 +405,6 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -467,7 +466,6 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand All @@ -492,11 +490,9 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = VerifyVerloop/VerifyVerloop.entitlements;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 19;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 729M345S3Z;
DEVELOPMENT_TEAM = 5423774D8G;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/VerifyVerloop",
Expand All @@ -518,8 +514,6 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.tg.SampleVerloopiOSApp;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = WildCard_Profile;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -532,11 +526,9 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = VerifyVerloop/VerifyVerloop.entitlements;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 19;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 729M345S3Z;
DEVELOPMENT_TEAM = 5423774D8G;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/VerifyVerloop",
Expand All @@ -558,8 +550,6 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.tg.SampleVerloopiOSApp;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = WildCard_Profile;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1540"
LastUpgradeVersion = "1310"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
5 changes: 4 additions & 1 deletion VerifyVerloop/VerifyVerloop/VerifyVerloop.entitlements
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
<dict>
<key>aps-environment</key>
<string>production</string>
</dict>
</plist>
8 changes: 6 additions & 2 deletions VerloopSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,9 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_STYLE = Manual;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -569,6 +570,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = io.verloop.VerloopSDK;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
Expand All @@ -581,8 +583,9 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_STYLE = Manual;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -596,6 +599,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = io.verloop.VerloopSDK;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
Loading