Skip to content

Instantly share code, notes, and snippets.

View mobilequickie's full-sized avatar

Mobile Quickie mobilequickie

View GitHub Profile
@mobilequickie
mobilequickie / info.plist.xml
Created October 11, 2018 16:08
Facebook Login metadata for Info.plist on iOS
<!-- START OF FACEBOOK PLIST ENTRIES HERE -->
<key>FacebookAppID</key>
<string>1234567891234567</string>
<key>FacebookDisplayName</key>
<string>Auth Demo</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-share-api</string>
<string>fbauth2</string>
@mobilequickie
mobilequickie / aws-cli-pinpoint-endpoint-update
Created September 20, 2018 17:43
AWS CLI command to update Amazon Pinpoint endpoint
aws pinpoint update-endpoint \
--application-id "a440cd17fe2b44a8b598f7xxxxxxxxxx" \
--endpoint-id "F2115F34-F064-4AB6-8621-XXXXXXXXXXXX" \
--endpoint-request file://endpointrequest.json
//Get the Amazon Pinpoint EndpointId from the device
let profile: AWSPinpointEndpointProfile = (pinpoint?.targetingClient.currentEndpointProfile())!
print("EndpointId: \(profile.endpointId)")
@mobilequickie
mobilequickie / endpointrequest.json
Last active September 20, 2018 17:37
Pinpoint EndpointRequest
{
"ChannelType": "SMS",
"Address": "+12065551212",
"Demographic": {
"AppVersion": "1.0",
"Make": "apple",
"Model": "iPhone",
"ModelVersion": "iPhone X",
"Platform": "ios",
"PlatformVersion": "12.0",
@mobilequickie
mobilequickie / recordCustomProfileDemographics.swift
Created September 6, 2018 23:16
Function inside of AWSAnalyticsService class that updates custom attributes for collecting demographics in Amazon Pinpoint
// Send custom model and platformVersion for this device to Amazon Pinpoint
func recordCustomProfileDemographics() {
let profile: AWSPinpointEndpointProfile = (pinpoint?.targetingClient.currentEndpointProfile())!
// Call our DeviceUtility class for readable Apple model type and iOS version for this device
profile.demographic?.model = UIDevice.current.modelName
profile.demographic?.platformVersion = UIDevice.current.systemVersion
pinpoint?.targetingClient.update(profile)
}
@mobilequickie
mobilequickie / DeviceUtility.swift
Last active March 14, 2022 20:37
Utility for deciphering iOS device names from identifier
// Updated April 8 for iPad Mini 5th gen, iPad Air 3rd gen, and all Apple Watch to gen 4.
// Updated Oct 9 for iPhone XS, iPhone XS Max, and iPhone XR
// Call this from any class that needs it: let modelName = UIDevice.current.modelName
// More here: https://gist.github.com/adamawolf/3048717
// Source of internal names came from this wiki: https://www.theiphonewiki.com/wiki/
import UIKit
public extension UIDevice {
@mobilequickie
mobilequickie / AWSAnalyticsService.swift
Created August 31, 2018 23:19
AnalyticsService AWS
import Foundation
import AWSCore
import AWSPinpoint
class AWSAnalyticsService : AnalyticsService {
var pinpoint: AWSPinpoint?
init() {
let config = AWSPinpointConfiguration.defaultPinpointConfiguration(launchOptions: nil)
pinpoint = AWSPinpoint(configuration: config)
@mobilequickie
mobilequickie / Podfile
Created August 31, 2018 23:17
Podfile
target 'MyNotes' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Analytics dependency
pod 'AWSPinpoint'
end
@mobilequickie
mobilequickie / LocalAnalyticsService.swift
Created August 31, 2018 23:13
AnalyticsService Local
import Foundation
class LocalAnalyticsService : AnalyticsService {
init() {
print("LocalAnalyticsService: session-start")
}
func recordEvent(_ eventName: String, parameters: [String : String]?, metrics: [String : Double]?) {
var event = ""
if (parameters != nil) {
@mobilequickie
mobilequickie / AnalyticsService.swift
Created August 31, 2018 23:10
AnalyticsService Protocol
protocol AnalyticsService {
func recordEvent(_ eventName: String, parameters: [String:String]?, metrics: [String:Double]?) -> Void
}