Skip to content

Instantly share code, notes, and snippets.

View ArchieR7's full-sized avatar
👨‍💻

Archie Chang ArchieR7

👨‍💻
View GitHub Profile
func applePay() {
let request = PKPaymentRequest()
request.merchantIdentifier = "merchant.tw.archie"
request.merchantCapabilities = .capability3DS
request.countryCode = "US"
request.currencyCode = "USD"
request.supportedNetworks = [.visa]
request.paymentSummaryItems = [PKPaymentSummaryItem.init(label: "Archie's shake hand", amount: 2000, type: .final)]
request.shippingType = .storePickup
let contact = PKContact()
from apns import ApnsPusher
ApnsPusher().push("Test Title", "Test Body", "device token", False)
@ArchieR7
ArchieR7 / requirements.txt
Created June 27, 2017 08:20
https://www.archie.tw/apns python APNs pusher requirements
cryptography
pyjwt
hyper
let notification = UILocalNotification()
notification.alertAction = "推播滑動的動作名稱"
notification.alertBody = "推播的內容"
notification.alertTitle = "推播的標題"
notification.soundName = UILocalNotificationDefaultSoundName
// 觸發條件以使用者的位置為主
let region = CLCircularRegion(center: center, radius: radius, identifier: ID)
// 可以設定當使用者進入或離開區域的時候,是否要跳出通知
region.notifyOnExit = false
region.notifyOnEntry = true
@ArchieR7
ArchieR7 / GADRewardBasedVideoAdDelegate.swift
Created June 26, 2017 02:20
AdMob Reward based video ad delegate
func rewardBasedVideoAd(_ rewardBasedVideoAd: GADRewardBasedVideoAd, didRewardUserWith reward: GADAdReward) {
//give user reward
}
func rewardBasedVideoAd(_ rewardBasedVideoAd: GADRewardBasedVideoAd, didFailToLoadWithError error: Error) {
print("Reward based video ad failed to load: \(error.localizedDescription)")
}
func rewardBasedVideoAdDidReceive(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
print("Reward based video ad is received.")
@ArchieR7
ArchieR7 / CheckAdMob.swift
Created June 26, 2017 02:17
Check AdMob is ready
if GADRewardBasedVideoAd.sharedInstance().isReady {
GADRewardBasedVideoAd.sharedInstance().present(fromRootViewController: self)
} else {
//do something
}
func loadAdMob() {
GADRewardBasedVideoAd.sharedInstance().delegate = self
let request = GADRequest()
GADRewardBasedVideoAd.sharedInstance().load(request, withAdUnitID: AdUnitID)
}
@ArchieR7
ArchieR7 / AppDelegate.swift
Created June 26, 2017 02:12
AppDelegate with AdMob
import Firebase
import GoogleMobileAds
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
GADMobileAds.configure(withApplicationID: Your_Ads_ApplicationID)
return true
}
@ArchieR7
ArchieR7 / podfile
Created June 26, 2017 02:08
CocoaPods with AdMob
pod 'Firebase/AdMob'
func setUpView() {
let loginButton = CircleButton()
loginButton.backgroundColor = UISetting.blue
}