Skip to content

Instantly share code, notes, and snippets.

View yunustek's full-sized avatar
🏠
Working from home

Yunus Tek yunustek

🏠
Working from home
View GitHub Profile
EarlGrey.select(elementWithMatcher: grey_text("Welcome"))
EarlGrey.select(elementWithMatcher: grey_accessibilityID("Add")).perform(grey_tap())
EarlGrey.select(elementWithMatcher: grey_accessibilityID("Username")).perform(grey_typeText("<Text>"))
@yunustek
yunustek / InstallAppium.txt
Created October 15, 2018 06:33
Install Appium
Install Appium
1. brew install node
2. npm install
3. npm install -g appium
4. npm install -g appium-doctor
5. npm install wd
6. brew install libimobiledevice --HEAD
7. brew install ideviceinstaller
8. npm install -g ios-deploy
9. sudo gem install xcpretty
@yunustek
yunustek / phoneNumberMaskPatern.txt
Created October 15, 2018 06:41
NSStringMask Mask Patern for Phone Number
// NSStringMask Mask Patern for Phone Number Format String
// - --- --- -- --
(\d{1}) (\d{3}) (\d{3}) (\d{2}) (\d{2})
// NSStringMask Mask Patern for Phone Number Format String
// - (---) --- -- --
(\d{1}) \((\d{3})\) (\d{3}) (\d{2}) (\d{2})
@yunustek
yunustek / NotificationService.Swift
Last active December 5, 2018 11:26
NotificationService.Swift
import UserNotifications
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
@yunustek
yunustek / PushNotificationApsDictionary.json
Last active December 5, 2018 11:44
PushNotificationApsDictionary.json
{
"aps" : {
"alert" : {
"title" : "Test Title Message",
"body" : "Yunus TEK"
},
"badge" : 1,
"sound": "default"
}
}
@yunustek
yunustek / PushNotificationApsDictionaryWithImage.json
Created December 5, 2018 11:59
PushNotificationApsDictionaryWithImage
{
"aps" : {
"alert" : {
"title" : "Test Title Message",
"body" : "Yunus TEK"
},
"badge" : 1,
"sound": "default",
"mutable-content":1
@yunustek
yunustek / DownloadImageFunc.m
Created December 5, 2018 12:21
DownloadImageFunc
/// Bir görüntüyü indirmek ve bir bildirimde sunmak için bu işlevi kullanın
/// - Parametereler:
/// - url: Resmin url'i
/// - completion: Görüntüyü, sonuç olarak UNNotificationAttachment biçiminde döndür
private func downloadImageFrom(url: URL, with completionHandler: @escaping (UNNotificationAttachment?) -> Void) {
let task = URLSession.shared.downloadTask(with: url) { (downloadedUrl, response, error) in
// 1. Url yoksa nil gönder ve geri dön
guard let downloadedUrl = downloadedUrl else {
completionHandler(nil)
return
@yunustek
yunustek / NotificationService-didReceive-updated.swift
Created December 5, 2018 12:31
NotificationService-didReceive-updated
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
guard let bestAttemptContent = bestAttemptContent, // 1. bestAttemptContent nil olmadığına emin ol
let apsData = bestAttemptContent.userInfo["aps"] as? [String: Any], // 2. Payload dan aps'i al
let attachmentURLAsString = apsData["mediaUrl"] as? String, // 3. mediaUrl'i al
let attachmentURL = URL(string: attachmentURLAsString) else { // 4. String'i URL'e çevir
return
}