Skip to content

Instantly share code, notes, and snippets.

View PH9's full-sized avatar
🚀
To infinite and beyond

Wasith 'Pi' Theerapattrathamrong PH9

🚀
To infinite and beyond
View GitHub Profile
import CoreTelephony
// Under iOS 12
func isThailandOperator() -> Bool {
let networkInfo = CTTelephonyNetworkInfo()
guard let carrier = networkInfo.subscriberCellularProvider else {
return false
}
guard let mcc = carrier.mobileCountryCode else {
import CoreTelephony
func getNetworkType() throws -> String {
let networkInfo = CTTelephonyNetworkInfo()
guard let accessTechnology = networkInfo.currentRadioAccessTechnology else {
throw ReachabilityError.cannotGetCurrentRadioAccessTechnology
}
return networkStringToReadableString(accessTechnology)
@PH9
PH9 / Network+isConnectToWiFi.swift
Last active November 3, 2019 07:37
Check is connected to WiFi
// https://developer.apple.com/library/archive/samplecode/Reachability/Introduction/Intro.html
func isConnectToWiFi() throws -> Bool {
guard let reachability = Reachability.forInternetConnection() else {
throw ReachabilityError.cannotCreateReachability
}
// 0 is not reachable
// 1 is WiFi
// 2 is Cellular
class Stack<T> {
private(set) var elements: [T] = []
func push(_ e: T) {
elements.append(e)
}
func pop() -> T? {
defer {
@PH9
PH9 / Fastfile
Last active August 29, 2019 08:11
Fastfile with .env
desc "build"
lane :build do |options|
build_ios_app(
configuration: ENV["BUILD_CONFIGURATION"],
export_options: {
method: ENV["EXPORT_METHOD"],
provisioningProfiles: {
ENV["APP_IDENTIFIER"] => ENV["APP_PROVISIONING_PROFILE"],
ENV["APP_NOTIFICATION_EXTENSION_ID"] => ENV["APP_NOTIFICATION_EXTENSION_PROVISIONING_PROFILE"]
}
@PH9
PH9 / Fastfile
Last active August 29, 2019 08:10
Fastfile with out .env
desc "build for Debug"
lane :build_debug do |options|
build_ios_app(
configuration: "Debug",
export_options: {
method: "development",
provisioningProfiles: {
"com.main.app" => "match Development com.main.app",
"com.main.app.extension" => "match Development com.main.app.extension"
}
{
"3.14.0": "https://www.gstatic.com/cpdc/c45591522c4ba5b8-GoogleIDFASupport-3.14.0.tar.gz",
"3.12.0": "https://www.gstatic.com/cpdc/d1b9837b3d4a0fd2-GoogleIDFASupport-3.12.0.tar.gz"
}
{
"3.17": "https://dl.google.com/googleanalyticsservices/GoogleAnalyticsServicesiOS_3.17.zip",
"3.13": "https://dl.google.com/googleanalyticsservices/GoogleAnalyticsServicesiOS_3.13.zip"
}
{
"3.17.0": "https://www.gstatic.com/cpdc/5cd71dd2f756bb01/GoogleAnalytics-3.17.0.tar.gz",
"3.16.0": "https://www.gstatic.com/cpdc/6f640c997e8d7455/GoogleAnalytics-3.16.0.tar.gz",
"3.14.0": "https://www.gstatic.com/cpdc/69fd9fe84a8fea60-GoogleAnalytics-3.14.0.tar.gz",
"3.13.0": "https://www.gstatic.com/cpdc/9b1bb5e186325dc2-GoogleAnalytics-3.13.0.tar.gz",
"3.12.0": "https://www.gstatic.com/cpdc/e2d01de47dc68c9e-GoogleAnalytics-3.12.0.tar.gz"
}
Feature Individual Paid individual Origanization Enterprise
Build app Limited Y Y Y
Test on Device Limited Limited Limited Y
Access beta release OS and Tools N Y Y Y
Advanced App Capabilities N Y Y Y
Distribute (not AppStore) N Limited Limited Unlimited
Submit to AppStore N Y Y N
Team management N N Y Y
D-U-N-S® Required N N Y Y