Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update example project #7

Merged
merged 1 commit into from
Jan 26, 2024
Merged
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
16 changes: 8 additions & 8 deletions Examples/SwiftExample/SwiftExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
5E19F59B2B477AE400E37F55 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5E19F5992B477AE400E37F55 /* Main.storyboard */; };
5E19F59D2B477AE400E37F55 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5E19F59C2B477AE400E37F55 /* Assets.xcassets */; };
5E19F5A02B477AE400E37F55 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5E19F59E2B477AE400E37F55 /* LaunchScreen.storyboard */; };
5EA7B6F02B549B6200C9B3AC /* messenger-sdk-ios in Frameworks */ = {isa = PBXBuildFile; productRef = 5EA7B6EF2B549B6200C9B3AC /* messenger-sdk-ios */; };
5ED8E9D92B64072C0007CD34 /* messenger-sdk-ios in Frameworks */ = {isa = PBXBuildFile; productRef = 5ED8E9D82B64072C0007CD34 /* messenger-sdk-ios */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -45,7 +45,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
5EA7B6F02B549B6200C9B3AC /* messenger-sdk-ios in Frameworks */,
5ED8E9D92B64072C0007CD34 /* messenger-sdk-ios in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -100,7 +100,7 @@
);
name = SwiftExample;
packageProductDependencies = (
5EA7B6EF2B549B6200C9B3AC /* messenger-sdk-ios */,
5ED8E9D82B64072C0007CD34 /* messenger-sdk-ios */,
);
productName = SwiftExample;
productReference = 5E19F5902B477AE400E37F55 /* SwiftExample.app */;
Expand Down Expand Up @@ -131,7 +131,7 @@
);
mainGroup = 5E19F5872B477AE400E37F55;
packageReferences = (
5EA7B6EE2B549B6200C9B3AC /* XCRemoteSwiftPackageReference "messenger-sdk-ios" */,
5ED8E9D72B64072C0007CD34 /* XCRemoteSwiftPackageReference "messenger-sdk-ios" */,
);
productRefGroup = 5E19F5912B477AE400E37F55 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -384,20 +384,20 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
5EA7B6EE2B549B6200C9B3AC /* XCRemoteSwiftPackageReference "messenger-sdk-ios" */ = {
5ED8E9D72B64072C0007CD34 /* XCRemoteSwiftPackageReference "messenger-sdk-ios" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/deskpro/messenger-sdk-ios.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 0.0.4;
minimumVersion = 0.0.5;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
5EA7B6EF2B549B6200C9B3AC /* messenger-sdk-ios */ = {
5ED8E9D82B64072C0007CD34 /* messenger-sdk-ios */ = {
isa = XCSwiftPackageProductDependency;
package = 5EA7B6EE2B549B6200C9B3AC /* XCRemoteSwiftPackageReference "messenger-sdk-ios" */;
package = 5ED8E9D72B64072C0007CD34 /* XCRemoteSwiftPackageReference "messenger-sdk-ios" */;
productName = "messenger-sdk-ios";
};
/* End XCSwiftPackageProductDependency section */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/deskpro/messenger-sdk-ios.git",
"state" : {
"revision" : "acd128d826940bf1ef4fbd551cc5afd5369196b9",
"version" : "0.0.4"
"revision" : "819692434d517e650d8c0b779760b6d5b764a45e",
"version" : "0.0.5"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "messenger-2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 1 addition & 15 deletions Examples/SwiftExample/SwiftExample/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
Expand Down Expand Up @@ -34,33 +35,18 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Y5K-21-oKc">
<rect key="frame" x="208" y="728" width="160" height="40"/>
<constraints>
<constraint firstAttribute="width" constant="160" id="9of-l3-DPd"/>
<constraint firstAttribute="height" constant="40" id="vNE-VM-pzV"/>
</constraints>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="filled" title="Open Messenger"/>
<connections>
<action selector="openTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="DWx-MK-K21"/>
</connections>
</button>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="UzI-FF-7q4" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="25" id="M19-eX-76Y"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="Y5K-21-oKc" secondAttribute="trailing" constant="25" id="Mq5-fE-0JS"/>
<constraint firstItem="iub-YM-rm0" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" constant="50" id="W8u-Ut-ooW"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="bottom" secondItem="Y5K-21-oKc" secondAttribute="bottom" constant="50" id="XqR-l0-O0A"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="UzI-FF-7q4" secondAttribute="trailing" constant="25" id="jdt-HL-ibz"/>
<constraint firstItem="iub-YM-rm0" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="25" id="q13-hQ-D4G"/>
<constraint firstItem="UzI-FF-7q4" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="top-hW-okP"/>
</constraints>
</view>
<connections>
<outlet property="openBtn" destination="Y5K-21-oKc" id="RMP-WK-DZO"/>
<outlet property="testBtn" destination="iub-YM-rm0" id="4XK-Wr-Mbm"/>
<outlet property="testLbl" destination="UzI-FF-7q4" id="Ywr-jt-hhw"/>
</connections>
Expand Down
23 changes: 16 additions & 7 deletions Examples/SwiftExample/SwiftExample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,36 @@ import DeskproFramework

class ViewController: UIViewController {

@IBOutlet weak var openBtn: UIButton!
@IBOutlet weak var testBtn: UIButton!
@IBOutlet weak var testLbl: UILabel!

//let messengerConfig = MessengerConfig(appUrl: "http://178.62.74.147:3001/d/", appId: "B0ED0B34-8507-4248-8738-0B0D80A6F7E9")
let messengerConfig = MessengerConfig(appUrl: "https://dev-pr-12670.earthly.deskprodemo.com/deskpro-messenger/deskpro/1/d/", appId: "")
let messengerConfig = MessengerConfig(appUrl: "https://dev-pr-12730.earthly.deskprodemo.com/deskpro-messenger/deskpro/1/d/", appId: "1")

var messenger: DeskPro?

override func viewDidLoad() {
super.viewDidLoad()

messenger = DeskPro(messengerConfig: messengerConfig, containingViewController: self)

setupLauncherButton()
}

@IBAction func testTapped(_ sender: Any) {
testLbl.text = messenger?.test()
}

@IBAction func openTapped(_ sender: Any) {
messenger?.present().show()
private func setupLauncherButton() {
let floatingBtn = DeskproButton()
floatingBtn.setColor(.systemBlue)
floatingBtn.setImage(named: "messenger", color: .white)
floatingBtn.addTarget(self, action: #selector(floatingBtnnTapped), for: .touchUpInside)
self.view.addSubview(floatingBtn)
floatingBtn.setPosition(.bottomRight, inView: self.view)
}

@IBAction func testTapped(_ sender: Any) {
testLbl.text = messenger?.test()
@objc private func floatingBtnnTapped() {
messenger?.present().show()
}
}

131 changes: 131 additions & 0 deletions Examples/SwiftExample/SwiftExample/error_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: 'Arial', sans-serif;
background-color: #f8f8f8;
margin: 0;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
.loading-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.8); /* Semi-transparent background */
z-index: 1; /* Place above other content */
animation: fadeInOut 3s linear; /* Animation duration and type */
}
@keyframes fadeInOut {
0%, 100% {
opacity: 1;
}
25%, 75% {
opacity: 0;
}
}
.loading-spinner {
border: 8px solid #3498db; /* Blue color */
border-top: 8px solid transparent;
border-radius: 50%;
width: 50px;
height: 50px;
animation: spin 1s linear infinite; /* Animation duration and type */
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.container {
text-align: center;
padding: 20px;
background-color: #ffffff;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border-radius: 8px;
z-index: 0; /* Place below the loading container */
display: none; /* Hide initially */
}
#warningIcon {
font-size: 48px;
color: #333; /* Black color */
margin-bottom: 10px;
}
h2 {
color: #333; /* Black color */
font-weight: bold;
margin-bottom: 10px;
}
p {
color: #555;
margin-bottom: 20px;
}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
background-color: #3498db; /* Blue color */
color: #ffffff;
border: none;
border-radius: 5px;
}
#closeButton {
position: absolute;
top: 10px;
right: 10px;
padding: 5px 10px;
font-size: 14px;
cursor: pointer;
background-color: #e74c3c; /* Red color */
color: #ffffff;
border: none;
border-radius: 3px;
}
</style>
</head>
<body>
<div class="loading-container" id="loadingContainer">
<div class="loading-spinner"></div>
<p>Loading...</p>
</div>
<div class="container" id="mainContent">
<button id="closeButton" onclick="closeWindow()">X</button>
<div id="warningIcon">&#9888;</div>
<h2>Something's gone wrong</h2>
<p>Content could not be loaded</p>
<button onclick="reloadPage()">Reload</button>
</div>
<script>
// Function to hide loading container and show main content
function showMainContent() {
document.getElementById('loadingContainer').style.display = 'none';
document.getElementById('mainContent').style.display = 'block';
}

// Simulate loading completion after 3 seconds
setTimeout(showMainContent, 3000);

function reloadPage() {
window.webkit.messageHandlers.iosListener.postMessage("reloadPage")
}

function closeWindow() {
window.webkit.messageHandlers.iosListener.postMessage("closeWebView")
}

</script>
</body>
</html>
Loading