Skip to content

Commit

Permalink
1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
z1tr0t3c committed Jun 2, 2021
1 parent 4e622be commit df0e48f
Show file tree
Hide file tree
Showing 7 changed files with 340 additions and 33 deletions.
1 change: 1 addition & 0 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ target 'blista' do

pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'SwiftyJSON', '~> 4.0'

end
6 changes: 5 additions & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ PODS:
- nanopb/encode (1.30906.0)
- PromisesObjC (1.2.10)
- Protobuf (3.13.0)
- SwiftyJSON (4.3.0)

DEPENDENCIES:
- Firebase/Core
- Firebase/Messaging
- SwiftyJSON (~> 4.0)

SPEC REPOS:
trunk:
Expand All @@ -97,6 +99,7 @@ SPEC REPOS:
- nanopb
- PromisesObjC
- Protobuf
- SwiftyJSON

SPEC CHECKSUMS:
Firebase: c23a36d9e4cdf7877dfcba8dd0c58add66358999
Expand All @@ -112,7 +115,8 @@ SPEC CHECKSUMS:
nanopb: 59317e09cf1f1a0af72f12af412d54edf52603fc
PromisesObjC: b14b1c6b68e306650688599de8a45e49fae81151
Protobuf: 3dac39b34a08151c6d949560efe3f86134a3f748
SwiftyJSON: 6faa0040f8b59dead0ee07436cbf76b73c08fd08

PODFILE CHECKSUM: 520344186de1f29c76e02112d62a271448eeb812
PODFILE CHECKSUM: c7a300f02ff7a4a60adc671fd33d1293385e5d7e

COCOAPODS: 1.10.1
6 changes: 4 additions & 2 deletions blista.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,15 @@
"${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework",
"${BUILT_PRODUCTS_DIR}/PromisesObjC/FBLPromises.framework",
"${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework",
"${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework",
"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBLPromises.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyJSON.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -589,7 +591,7 @@
INFOPLIST_FILE = blista/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 1.20.1;
MARKETING_VERSION = 1.20.2;
PRODUCT_BUNDLE_IDENTIFIER = de.zitrotec.blista;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -619,7 +621,7 @@
INFOPLIST_FILE = blista/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 1.20.1;
MARKETING_VERSION = 1.20.2;
PRODUCT_BUNDLE_IDENTIFIER = de.zitrotec.blista;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<key>blista.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>14</integer>
<integer>15</integer>
</dict>
</dict>
</dict>
Expand Down
225 changes: 225 additions & 0 deletions blista/FirstViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import UIKit
import Crashlytics
import SwiftyJSON

class FirstViewController: UIViewController, UIWebViewDelegate {

Expand All @@ -25,12 +26,236 @@ class FirstViewController: UIViewController, UIWebViewDelegate {
return
}
}

func activateMe() {

let alert = UIAlertController(title: "Bitte denk über eine Spende nach", message: "Die Entwicklung der blistar-App kostet viel Zeit und Geld. Spende für die blistar-App und sichere die Weiterentwicklung der App oder warte 60 Sekunden.", preferredStyle: .alert)

alert.addAction(UIAlertAction(title: "Spenden", style: .default, handler: { action in
let url = URL(string:"https://zitrotec.de/it-service/referenzen/blista/blistar-app-support-plan")

let reachability = Reachability()!

switch reachability.connection {
case .wifi:

if #available(iOS 10.0, *) {
UIApplication.shared.open(url!, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url!)
}
self.present(alert, animated: true)

case .cellular:

if #available(iOS 10.0, *) {
UIApplication.shared.open(url!, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url!)
}
self.present(alert, animated: true)

case .none:
let alert3 = UIAlertView()
alert3.title = "Du bist Offline"
alert3.message = "Bitte stell eine Internetverbindung her, um diesen Inhalt anzuzeigen."
alert3.addButton(withTitle: "OK")
alert3.show()
self.present(alert, animated: true)
}
}))

alert.addAction(UIAlertAction(title: "Spendenschlüssel eingeben", style: .default, handler: { action in

let alert2 = UIAlertController(title: "Spendenschlüssel", message: nil, preferredStyle: .alert)
alert2.addAction(UIAlertAction(title: "Abbrechen", style: .cancel, handler: { action in

self.present(alert, animated: true)

}))
alert2.addTextField(configurationHandler: { textField in
textField.placeholder = "Gib deinen Spendenschlüssel ein"
})

alert2.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in

let license = alert2.textFields![0]

if license.text != "" {
let licenseString = license.text!
print(licenseString)
UIApplication.shared.isNetworkActivityIndicatorVisible = true

guard let url = URL(string: "https://zitrotec.de/it-service/wp-admin/admin-ajax.php?action=license_key_activate&store_code=F3Up0N7tI87JWEp&sku=blistar-app-subscription-m&license_key=\(licenseString)") else {return}
let task = URLSession.shared.dataTask(with: url) { (data, response, error) in
guard let dataResponse = data,
error == nil else {
print(error?.localizedDescription ?? "Response Error")
UIApplication.shared.isNetworkActivityIndicatorVisible = false

DispatchQueue.main.async {
let alert5 = UIAlertController(title: "Fehler: " + (error?.localizedDescription ?? "Response Error"), message: "Hilfe zu diesem Fehler findest du auf der Spendenseite.", preferredStyle: UIAlertControllerStyle.alert)

let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {(action:UIAlertAction) in
self.present(alert, animated: true)
})

alert5.addAction(action)
self.present(alert5, animated: true, completion: nil)

}

return }
let json = try? JSON(data: dataResponse)
let status = json?["status"].stringValue
print(status ?? "null")
let error = json?["errors"]["license_key"][0].stringValue
print(error ?? "null")

if (status != "200") {

UIApplication.shared.isNetworkActivityIndicatorVisible = false

DispatchQueue.main.async {
let alert4 = UIAlertController(title: "Fehler: " + (error ?? "null"), message: "Hilfe zu diesem Fehler findest du auf der Spendenseite.", preferredStyle: UIAlertControllerStyle.alert)

let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {(action:UIAlertAction) in
self.present(alert, animated: true)
})

alert4.addAction(action)
self.present(alert4, animated: true, completion: nil)

}

}

else {

let message = json?["message"].stringValue

let activation_id = json?["data"]["activation_id"].stringValue

let expire_date = json?["data"]["expire_date"].stringValue

let the_key = json?["data"]["the_key"].stringValue

let url = json?["data"]["url"].stringValue

let has_expired = json?["data"]["has_expired"].stringValue

let status = json?["data"]["status"].stringValue

let ctoken = json?["data"]["ctoken"].stringValue

let name = json?["data"]["name"].stringValue

print("Message:")
print(message ?? "null");
print("activation_id:")
print(activation_id ?? "null");
print("expire_date:")
print(expire_date ?? "null");
print("the_key:")
print(the_key ?? "null");
print("url:")
print(url ?? "null");
print("has_expired:")
print(has_expired ?? "null");
print("status:")
print(status ?? "null");
print("ctoken:")
print(ctoken ?? "null");
print("name:")
print(name ?? "null");

let defaults = UserDefaults.standard

defaults.set(activation_id, forKey: "activation_id")
defaults.set(expire_date, forKey: "expire_date")
defaults.set(the_key, forKey: "the_key")
defaults.set(url, forKey: "url")
defaults.set(status, forKey: "status")
defaults.set(has_expired, forKey: "has_expired")
defaults.set(ctoken, forKey: "ctoken")
defaults.set(name, forKey: "name")
defaults.set(true, forKey: "active")

let UserInfo1 = "Abo: \n" + (name ?? "null")
let UserInfo2 = "\n Ablaufdatum: \n" + (expire_date ?? "null")
let UserInfo3 = "\n Aktivierungs-ID: \n" + (activation_id ?? "null")
let UserInfo = UserInfo1 + UserInfo2 + UserInfo3

UIApplication.shared.isNetworkActivityIndicatorVisible = false


DispatchQueue.main.async {
let alert7 = UIAlertController(title: "Erfolg: " + (message ?? "null"), message: "Vielen Dank für deine Unterstützung, die 60 Sek. Wartezeit entfällt nun. \n Details: \n" + (UserInfo ), preferredStyle: UIAlertControllerStyle.alert)

let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {(action:UIAlertAction) in
// Spark!
})

alert7.addAction(action)
self.present(alert7, animated: true, completion: nil)

}

}

}
task.resume()


} else {

self.present(alert2, animated: true)

}

}))

self.present(alert2, animated: true)

}))

self.present(alert, animated: true)
}

override func viewDidLoad() {
super.viewDidLoad()

// Do any additional setup after loading the view, typically from a nib.

let defaults = UserDefaults.standard

let activation_id = defaults.string(forKey: "activation_id")
let the_key = defaults.string(forKey: "the_key")
let url = defaults.string(forKey: "url")
let status = defaults.string(forKey: "status")
let has_expired = defaults.bool(forKey: "has_expired")
let ctoken = defaults.string(forKey: "ctoken")
let name = defaults.string(forKey: "name")
let active = defaults.bool(forKey: "active")


let launchedBefore = defaults.bool(forKey: "launchedBefore")
if launchedBefore
{
print("Not first launch.")
if !active {
activateMe()
DispatchQueue.main.asyncAfter(deadline: .now() + 60.0) {
self.dismiss(animated: true, completion: nil)
}
}
}
else
{
print("First launch")
defaults.set(true, forKey: "launchedBefore")
}

segmentedControl.sendActions(for: UIControlEvents.valueChanged)
}

Expand Down
Loading

0 comments on commit df0e48f

Please sign in to comment.