Commit f714d29f authored by jzhang's avatar jzhang

更新友盟统计sdk适配、添加隐私协议功能

parent 23dd01b4
......@@ -175,6 +175,9 @@
6699F9B9297293860042B6FB /* NSObject+Category.m in Sources */ = {isa = PBXBuildFile; fileRef = 6699F9A3297293860042B6FB /* NSObject+Category.m */; };
6699F9BA297293860042B6FB /* UIColor+Category.m in Sources */ = {isa = PBXBuildFile; fileRef = 6699F9A4297293860042B6FB /* UIColor+Category.m */; };
8E99375C209056F5000CF486 /* Appdelegate+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E99375B209056F5000CF486 /* Appdelegate+Extension.swift */; };
EADB8EF32973BE4700BB262F /* UserPrivacyProtocolView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EADB8EF02973BE4700BB262F /* UserPrivacyProtocolView.swift */; };
EADB8EF42973BE4700BB262F /* UserPrivacyProtocolView.xib in Resources */ = {isa = PBXBuildFile; fileRef = EADB8EF12973BE4700BB262F /* UserPrivacyProtocolView.xib */; };
EADB8EF52973BE4700BB262F /* UserPrivacyProtocolVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = EADB8EF22973BE4700BB262F /* UserPrivacyProtocolVC.swift */; };
F04C5934BDBBB8EA12141331 /* Pods_IFS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 35B66002AC5D38FD80592FA3 /* Pods_IFS.framework */; };
/* End PBXBuildFile section */
......@@ -379,6 +382,9 @@
8E99375A2090550C000CF486 /* IFS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = IFS.entitlements; sourceTree = "<group>"; };
8E99375B209056F5000CF486 /* Appdelegate+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Appdelegate+Extension.swift"; sourceTree = "<group>"; };
A6BACB82FD689EB241DCA577 /* Pods-IFS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-IFS.release.xcconfig"; path = "Pods/Target Support Files/Pods-IFS/Pods-IFS.release.xcconfig"; sourceTree = "<group>"; };
EADB8EF02973BE4700BB262F /* UserPrivacyProtocolView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserPrivacyProtocolView.swift; sourceTree = "<group>"; };
EADB8EF12973BE4700BB262F /* UserPrivacyProtocolView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = UserPrivacyProtocolView.xib; sourceTree = "<group>"; };
EADB8EF22973BE4700BB262F /* UserPrivacyProtocolVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserPrivacyProtocolVC.swift; sourceTree = "<group>"; };
F6BA9AE73F42B2E00206B76C /* Pods-IFS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-IFS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-IFS/Pods-IFS.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
......@@ -746,6 +752,7 @@
29EA0BAB1FEA3156005A6170 /* Main */ = {
isa = PBXGroup;
children = (
EADB8EEF2973BE4700BB262F /* UserPrivacy */,
29EA0BB61FEA3156005A6170 /* Home */,
29EA0BB11FEA3156005A6170 /* Business */,
29EA0BAC1FEA3156005A6170 /* Account */,
......@@ -1161,6 +1168,16 @@
name = Pods;
sourceTree = "<group>";
};
EADB8EEF2973BE4700BB262F /* UserPrivacy */ = {
isa = PBXGroup;
children = (
EADB8EF02973BE4700BB262F /* UserPrivacyProtocolView.swift */,
EADB8EF12973BE4700BB262F /* UserPrivacyProtocolView.xib */,
EADB8EF22973BE4700BB262F /* UserPrivacyProtocolVC.swift */,
);
path = UserPrivacy;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
......@@ -1234,6 +1251,7 @@
29A8D9A72011C602001E865C /* RepairAttachmentTableViewCell.xib in Resources */,
296FE4401FFB2D3400810820 /* Function.storyboard in Resources */,
29B0C66C1FEA3A7000FF37ED /* LaunchScreen.storyboard in Resources */,
EADB8EF42973BE4700BB262F /* UserPrivacyProtocolView.xib in Resources */,
296FE4581FFB7CED00810820 /* function.plist in Resources */,
29516A92200DEE9500C3A17E /* RepairOrderAttachmentTableViewCell.xib in Resources */,
294BE8002080431500F783F8 /* YXBundle.bundle in Resources */,
......@@ -1417,6 +1435,7 @@
29DA418B200475AC002762A2 /* AccountViewModel.swift in Sources */,
296DAD82200711CA00615A2D /* InitiatorModel.swift in Sources */,
29EA0C011FEA3156005A6170 /* BaseColletionViewPullController.swift in Sources */,
EADB8EF52973BE4700BB262F /* UserPrivacyProtocolVC.swift in Sources */,
29D530801FFF626500851F00 /* RepairOrderViewController.swift in Sources */,
294BE7FF2080431500F783F8 /* YXAddressPickerView.m in Sources */,
29D530911FFF6FA800851F00 /* PhotoAttachmentViewController.swift in Sources */,
......@@ -1492,6 +1511,7 @@
29EA0BFD1FEA3156005A6170 /* AppStyle.swift in Sources */,
296AACB31FFE31FC008BE04C /* FilterViewModel.swift in Sources */,
34CB3FAF21097B0400E41667 /* TreeFliteLocationCell.swift in Sources */,
EADB8EF32973BE4700BB262F /* UserPrivacyProtocolView.swift in Sources */,
29DA418D200486D6002762A2 /* ChangePasswordTableViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
......
//
// AgreementWebVC.swift
// CStoreEdu-iOS
//
// Created by jzhang on 2022/8/25.
//
import UIKit
import WebKit
class UserPrivacyProtocolVC: UIViewController {
lazy var webView: WKWebView = .init()
override func viewDidLoad() {
super.viewDidLoad()
title = "隐私协议"
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(close))
view.addSubview(webView)
webView.snp.makeConstraints { make in
make.top.left.bottom.right.equalToSuperview()
}
let request = URLRequest(url: URL(string: "http://www.gomoretech.com/privacy.html")!)
webView.load(request)
}
@objc func close() {
dismiss(animated: true)
UserPrivacyProtocolManager.shared.addAlert()
}
}
//
// AgreementAlertV.swift
// CStoreEdu-iOS
//
// Created by jzhang on 2022/8/25.
//
import Alamofire
import UIKit
import YXAlertController
class UserPrivacyProtocolView: UIView {
@IBOutlet var textView: UITextView!
override func awakeFromNib() {
print("\(self) init")
let string = """
亲爱的用户,感谢您信任并使用本APP!
我们非常重视保护您的隐私及个人信息,依据相关法律制定了《用户隐私政策》向您推送提示。
您点击“同意”即表示您已阅读并同意上述条款。
我们竭力保障您的合法权益与信息安全,并继续为您提供优质服务
您可阅读完整版《用户隐私政策》
"""
let attString = NSMutableAttributedString(string: string)
attString.set(text: "《用户隐私政策》", attributes: [.link: "http://www.gomoretech.com/privacy.html"])
// textView.linkTextAttributes = [.foregroundColor: MainColor, .underlineStyle: NSUnderlineStyle.single.rawValue]
textView.attributedText = attString
textView.delegate = self
}
override func layoutSubviews() {
super.layoutSubviews()
textView.setContentOffset(.zero, animated: false)
}
@IBAction func tapAgreeAction(_ sender: Any) {
UserPrivacyProtocolManager.shared.setStatus(true)
UserPrivacyProtocolManager.shared.dismissAlert()
}
@IBAction func tapDisagreeAction(_ sender: Any) {
UserPrivacyProtocolManager.shared.dismissAlert()
ShowAlertView("温馨提示", "您需要同意用户隐私协议才能继续使用软件哦~", ["同意并继续使用", "退出应用"], UIAlertController.Style.alert) { index in
if index == 1 {
UserPrivacyProtocolManager.shared.setStatus(false)
fatalError()
} else {
UserPrivacyProtocolManager.shared.setStatus(true)
}
}
}
deinit {
print("\(self) deinit")
}
}
extension UserPrivacyProtocolView: UITextViewDelegate {
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
UserPrivacyProtocolManager.shared.dismissAlert()
let webVC = UserPrivacyProtocolVC()
let vc = BaseNavigationController(rootViewController: webVC)
UserPrivacyProtocolManager.shared.parentViewController?.present(vc, animated: true)
return false
}
}
class UserPrivacyProtocolManager: NSObject {
static let shared: UserPrivacyProtocolManager = .init()
weak var alertView: UserPrivacyProtocolView?
weak var shadowView: UIView?
weak var parentViewController: UIViewController?
let key = "agreement_key"
override init() {
super.init()
if UserDefaults.standard.bool(forKey: key) {
agreedPrivacy()
}
}
func setStatus(_ st: Bool) {
UserDefaults.standard.setValue(st, forKey: key)
UserDefaults.standard.synchronize()
if st {
agreedPrivacy()
}
}
func dismissAlert() {
alertView?.removeFromSuperview()
shadowView?.removeFromSuperview()
}
func addAlert() {
guard shadowView == nil else { return }
guard let keyWindow = UIApplication.shared.windows.filter({ $0.isKeyWindow }).first else { return }
let shadowView = UIView(frame: .zero)
shadowView.backgroundColor = .black.withAlphaComponent(0.2)
let alertView = UserPrivacyProtocolView.instantiateFromNib() as! UserPrivacyProtocolView
keyWindow.addSubview(shadowView)
shadowView.snp.makeConstraints { make in
make.top.left.bottom.right.equalToSuperview()
}
keyWindow.addSubview(alertView)
alertView.snp.makeConstraints { make in
make.height.width.equalTo(UIScreen.main.bounds.size.width - 16 * 2)
make.centerX.centerY.equalToSuperview()
}
self.shadowView = shadowView
self.alertView = alertView
}
@discardableResult
@objc func checkAgreement(_ vc: UIViewController) -> Bool {
if UserDefaults.standard.bool(forKey: key) {
return true
}
parentViewController = vc
addAlert()
return false
}
fileprivate func agreedPrivacy() {
setupUM()
}
/// 设置友盟统计
fileprivate func setupUM() {
UMConfigure.initWithAppkey(UMKey, channel: "")
UMConfigure.setLogEnabled(true)
MobClick.setAutoPageEnabled(true)
}
}
extension NSMutableAttributedString {
func set(text: String, attributes: [NSAttributedString.Key: Any]) {
let ranges = string.ranges(of: text)
for range in ranges.map({ NSRange($0, in: string) }) {
addAttributes(attributes, range: range)
}
}
}
extension String {
func indices(of occurrence: String) -> [Int] {
var indices = [Int]()
var position = startIndex
while let range = range(of: occurrence, range: position ..< endIndex) {
let i = distance(from: startIndex,
to: range.lowerBound)
indices.append(i)
let offset = occurrence.distance(from: occurrence.startIndex, to: occurrence.endIndex) - 1
guard let after = index(range.lowerBound, offsetBy: offset, limitedBy: endIndex)
else {
break
}
position = index(after: after)
}
return indices
}
func ranges(of searchString: String) -> [Range<String.Index>] {
let _indices = indices(of: searchString)
let count = searchString.count
return _indices.map { index(startIndex, offsetBy: $0) ..< index(startIndex, offsetBy: $0 + count) }
}
}
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="UserPrivacyProtocolView" customModule="CStoreEdu_iOS" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="414" height="643"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="温馨提示" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="18G-y8-k0J">
<rect key="frame" x="0.0" y="68" width="414" height="25.5"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="21"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="r2O-lb-keV">
<rect key="frame" x="0.0" y="559" width="414" height="68"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="GE5-MU-qXV">
<rect key="frame" x="0.0" y="0.0" width="414" height="40"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="Asu-Mz-9I4"/>
</constraints>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="同意并开始使用"/>
<connections>
<action selector="tapAgreeAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="xHB-JZ-fCa"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="mTu-Xb-IXx">
<rect key="frame" x="0.0" y="48" width="414" height="20"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="z46-7d-ixy"/>
</constraints>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="不同意">
<color key="titleColor" systemColor="systemGrayColor"/>
</state>
<connections>
<action selector="tapDisagreeAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="T8R-uX-oMD"/>
</connections>
</button>
</subviews>
</stackView>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tJd-ae-Ef5">
<rect key="frame" x="16" y="93.5" width="382" height="457.5"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<string key="text">亲爱的用户,感谢您信任并使用华东番茄学院!
我们非常重视保护您的隐私及个人信息,依据相关法律制定了《用户隐私政策》向您推送提示。
您点击“同意”即表示您已阅读并同意上述条款。
我们竭力保障您的合法权益与信息安全,并继续为您提供优质服务
您可阅读完整版《用户隐私政策》</string>
<color key="textColor" systemColor="labelColor"/>
<fontDescription key="fontDescription" name=".AppleSystemUIFont" family=".AppleSystemUIFont" pointSize="15"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
</subviews>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="18G-y8-k0J" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="0TT-PG-TU5"/>
<constraint firstItem="tJd-ae-Ef5" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="16" id="45t-A9-Ndb"/>
<constraint firstItem="tJd-ae-Ef5" firstAttribute="top" secondItem="18G-y8-k0J" secondAttribute="bottom" id="5bc-lf-hlK"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="r2O-lb-keV" secondAttribute="bottom" constant="16" id="F4d-Au-GPn"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="18G-y8-k0J" secondAttribute="trailing" id="QTX-JC-tIk"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="r2O-lb-keV" secondAttribute="trailing" id="Uty-N7-acA"/>
<constraint firstAttribute="trailing" secondItem="tJd-ae-Ef5" secondAttribute="trailing" constant="16" id="ZWn-0m-qQJ"/>
<constraint firstItem="18G-y8-k0J" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="24" id="aHW-hn-WOJ"/>
<constraint firstItem="r2O-lb-keV" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="f4k-R8-nty"/>
<constraint firstItem="r2O-lb-keV" firstAttribute="top" secondItem="tJd-ae-Ef5" secondAttribute="bottom" constant="8" id="hP3-Kw-A17"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="textView" destination="tJd-ae-Ef5" id="rRJ-5E-9gH"/>
</connections>
<point key="canvasLocation" x="131.8840579710145" y="174.44196428571428"/>
</view>
</objects>
<resources>
<systemColor name="labelColor">
<color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="systemGrayColor">
<color red="0.55686274509803924" green="0.55686274509803924" blue="0.57647058823529407" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
......@@ -35,9 +35,9 @@ class AppStyle: NSObject {
SVProgressHUD.setMinimumDismissTimeInterval(TimeInterval(CGFloat.greatestFiniteMagnitude))
SVProgressHUD.resetOffsetFromCenter()
SVProgressHUD.setDefaultMaskType(.clear)
UMAnalyticsConfig.sharedInstance().appKey = UMKey
MobClick.start(withConfigure: UMAnalyticsConfig.sharedInstance())
MobClick.setLogEnabled(true)
// UMAnalyticsConfig.sharedInstance().appKey = UMKey
// MobClick.start(withConfigure: UMAnalyticsConfig.sharedInstance())
// MobClick.setLogEnabled(true)
}
}
......
......@@ -41,6 +41,11 @@ class LoginViewController: UIViewController {
bindingRxAction()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
UserPrivacyProtocolManager.shared.checkAgreement(self)
}
// MARK: - UI
fileprivate func uiConfigAction() {
loginButton.addAngle(25.0)
......
......@@ -6,12 +6,13 @@
#import "UINavigationController+FDFullscreenPopGesture.h"
#import "YXKitHeader.h"
#import "YXPickerManager.h"
#import <UMCommon/UMCommon.h>
#import <UMCommon/MobClick.h>
@import YXAlertController;
#import "IQTextView.h"
#import "UIDevice+Helper.h"
#import "NSString+Helper.h"
#import <CommonCrypto/CommonCrypto.h>
#import <UMMobClick/MobClick.h>
@import RATreeView;
@import MZFormSheetPresentationController;
// 引入JPush功能所需头文件
......
......@@ -24,6 +24,6 @@ target "IFS" do
pod "SVProgressHUD", "~> 2.2.2"
pod "swiftScan", :git => "https://github.com/MxABC/swiftScan.git"
pod "SwiftyJSON"
pod "UMengAnalytics"
pod "UMCommon"
pod "YXAlertController"
end
......@@ -34,7 +34,9 @@ PODS:
- SVProgressHUD (2.2.5)
- swiftScan (1.2.1)
- SwiftyJSON (5.0.1)
- UMengAnalytics (4.2.4)
- UMCommon (7.3.8):
- UMDevice
- UMDevice (2.2.1)
- YXAlertController (1.1.0)
DEPENDENCIES:
......@@ -59,7 +61,7 @@ DEPENDENCIES:
- SVProgressHUD (~> 2.2.2)
- swiftScan (from `https://github.com/MxABC/swiftScan.git`)
- SwiftyJSON
- UMengAnalytics
- UMCommon
- YXAlertController
SPEC REPOS:
......@@ -88,7 +90,8 @@ SPEC REPOS:
- SnapKit
- SVProgressHUD
- SwiftyJSON
- UMengAnalytics
- UMCommon
- UMDevice
- YXAlertController
EXTERNAL SOURCES:
......@@ -132,9 +135,10 @@ SPEC CHECKSUMS:
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
swiftScan: 0849e7d7c1c641384767a573ee8cb90b88d1ddd9
SwiftyJSON: 2f33a42c6fbc52764d96f13368585094bfd8aa5e
UMengAnalytics: ef8d45f94c0e5771dc364cf6a5731d9d3b101da2
UMCommon: fdb5bac9e7ec2aca4f9cfc0febf414b59ed302cb
UMDevice: 053478c4b4d7292f31f0a275c227d3c4007a5571
YXAlertController: 8234d980cda27a86a285faea140a3c8676bca768
PODFILE CHECKSUM: dd0794c6b5360eed685bedd16b0e46d7843eceea
PODFILE CHECKSUM: 20f08c30234bd1bff92a8889eaf94bc14ae3c313
COCOAPODS: 1.11.3
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment