Skip to content

Instantly share code, notes, and snippets.

View dmennis's full-sized avatar

Dennis Hills dmennis

View GitHub Profile
func pushNotificationHandler(userInfo: Dictionary<AnyHashable,Any>) {
// Parse the aps payload
let apsPayload = userInfo["aps"] as! [String: AnyObject]
// Play custom push notification sound (if exists) by parsing out the "sound" key and playing the audio file specified
// For example, if the incoming payload is: { "sound":"tarzanwut.aiff" } the app will look for the tarzanwut.aiff file in the app bundle and play it
if let mySoundFile : String = apsPayload["sound"] as? String {
playSound(fileName: mySoundFile)
}
}
type Settings {
theme: String
displayName: String
signature: String
requestAlert: Boolean
}
type Query {
getSettings: Settings!
}
---
AWSTemplateFormatVersion: '2010-09-09'
Description: Mobile App CICD Demo
Parameters:
DeviceFarmProjectName:
Type: String
Default: demo-app-devicefarm
@dmennis
dmennis / CreateAmplifyIAMUserCreds.yaml
Last active March 28, 2019 16:25
A CloudFormation template to create an Amplify IAM user, inline IAM policy, and credentials (key/secret) to be used with the Amplify CLI
AWSTemplateFormatVersion: '2010-09-09'
Description: "This template is used by the master organizations account to provision a new IAM User, assign an IAM Policy, and get credentials to build apps using AWS Amplify"
Resources:
# This will create a new IAM User with enough privileges for an AWS Amplify developer to build cloud-enabled apps using the Amplify CLI, Amplify Console, AppSync, APIGW, Lambda, Pinpoint, and DynamoDB
AWSAmplifyDeveloperIAMUser:
Type: "AWS::IAM::User"
Properties:
LoginProfile:
Password: "AmplifyH@ck$"
// Initialize Identity Provider
let credentialsProvider = AWSCognitoCredentialsProvider(
regionType: .USWest2,
identityPoolId: "us-east-1:12345678-d9ba-4bdc-9a79-085e9f20c1ai")
let configuration = AWSServiceConfiguration(
region: .USWest2,
credentialsProvider: credentialsProvider)
AWSServiceManager.default().defaultServiceConfiguration = configuration
rekognitionObject = AWSRekognition.default()
let celebImageAWS = AWSRekognitionImage()
celebImageAWS?.bytes = celebImageData
let celebRequest = AWSRekognitionRecognizeCelebritiesRequest()
celebRequest?.image = celebImageAWS
rekognitionObject?.recognizeCelebrities(celebRequest!){
(result, error) in
if error != nil{
print(error!)
return
}
//1. First we check if there are any celebrities in the response
if ((result!.celebrityFaces?.count)! > 0){
rekognitionObject?.recognizeCelebrities(celebRequest!){
(result, error) in
if error != nil{
print(error!)
return
}
if result != nil{
print(result!)
}
else{
@dmennis
dmennis / AuthViewController2.7.swift
Last active December 13, 2018 22:43
AWSMobileClient code for implementing basic auth or federated login using the AWS SDK for iOS and AWS Amplify Framework (CLI) - 2.7.0+
//
// AuthViewController.swift
//
// Created by Hills, Dennis on 12/13/2018.
// Copyright © 2018 Hills, Dennis. All rights reserved.
//
// About: Using AWS Amplify Framework for iOS 2.7.0+ to implement Basic Auth via Cognito User Pools with example Facebook option
// This sample includes the userState listener and AWSMobileClient implementation changes added to iOS SDK for AWS v.2.7.0+
//
// AWS Amplify Documentation: https://aws-amplify.github.io/docs/ios/authentication
@dmennis
dmennis / BasicAuthViewController2.7.swift
Last active March 19, 2019 18:39
AWS SDK for iOS 2.7.0+
import UIKit
import AWSMobileClient
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
initializeAWSMobileClient() // Initialize the AWSMobileClient
}