Skip to content

Commit 0cdcaf9

Browse files
authored
Merge pull request #813 from peterfriese/SiwA-Swift
Add support for Sign in with Apple.
2 parents 6a3a357 + 9bc9268 commit 0cdcaf9

File tree

3 files changed

+42
-11
lines changed

3 files changed

+42
-11
lines changed

samples/swift/FirebaseUI-demo-swift/FirebaseUI-demo-swift.entitlements

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@
44
<dict>
55
<key>aps-environment</key>
66
<string>development</string>
7+
<key>com.apple.developer.applesignin</key>
8+
<array>
9+
<string>Default</string>
10+
</array>
711
</dict>
812
</plist>

samples/swift/FirebaseUI-demo-swift/Resources/Main.storyboard

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14865.1" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="jBB-7b-HHb">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="jBB-7b-HHb">
33
<device id="retina4_7" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14819.2"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15703"/>
77
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
88
</dependencies>
99
<scenes>
@@ -333,9 +333,26 @@
333333
</subviews>
334334
</tableViewCellContentView>
335335
</tableViewCell>
336-
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" textLabel="W38-CF-prR" style="IBUITableViewCellStyleDefault" id="5OH-mh-Vu8">
336+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" textLabel="nyZ-dU-P3i" style="IBUITableViewCellStyleDefault" id="OSr-RE-liP">
337337
<rect key="frame" x="0.0" y="402.5" width="375" height="44"/>
338338
<autoresizingMask key="autoresizingMask"/>
339+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="OSr-RE-liP" id="kF8-AN-AZ1">
340+
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
341+
<autoresizingMask key="autoresizingMask"/>
342+
<subviews>
343+
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Apple" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="nyZ-dU-P3i">
344+
<rect key="frame" x="16" y="0.0" width="343" height="44"/>
345+
<autoresizingMask key="autoresizingMask"/>
346+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
347+
<nil key="textColor"/>
348+
<nil key="highlightedColor"/>
349+
</label>
350+
</subviews>
351+
</tableViewCellContentView>
352+
</tableViewCell>
353+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" textLabel="W38-CF-prR" style="IBUITableViewCellStyleDefault" id="5OH-mh-Vu8">
354+
<rect key="frame" x="0.0" y="446.5" width="375" height="44"/>
355+
<autoresizingMask key="autoresizingMask"/>
339356
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="5OH-mh-Vu8" id="kxd-58-cMN">
340357
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
341358
<autoresizingMask key="autoresizingMask"/>
@@ -355,7 +372,7 @@
355372
<tableViewSection headerTitle="Sign In Anonymously" id="xoI-Ss-uCp">
356373
<cells>
357374
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" textLabel="I2w-bW-GAA" style="IBUITableViewCellStyleDefault" id="d1V-gz-BAF">
358-
<rect key="frame" x="0.0" y="485.5" width="375" height="44"/>
375+
<rect key="frame" x="0.0" y="529.5" width="375" height="44"/>
359376
<autoresizingMask key="autoresizingMask"/>
360377
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="d1V-gz-BAF" id="evf-nq-W89">
361378
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
@@ -376,7 +393,7 @@
376393
<tableViewSection headerTitle="Name" id="Jho-f6-Urp">
377394
<cells>
378395
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="mXf-Qr-aGq">
379-
<rect key="frame" x="0.0" y="568.5" width="375" height="44"/>
396+
<rect key="frame" x="0.0" y="612.5" width="375" height="44"/>
380397
<autoresizingMask key="autoresizingMask"/>
381398
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="mXf-Qr-aGq" id="VWa-qt-FWa">
382399
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
@@ -388,7 +405,7 @@
388405
<tableViewSection headerTitle="e-mail" id="Acz-Do-HDT">
389406
<cells>
390407
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="IjQ-eL-x0N">
391-
<rect key="frame" x="0.0" y="651.5" width="375" height="44"/>
408+
<rect key="frame" x="0.0" y="695.5" width="375" height="44"/>
392409
<autoresizingMask key="autoresizingMask"/>
393410
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="IjQ-eL-x0N" id="kVz-NE-XOf">
394411
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
@@ -400,7 +417,7 @@
400417
<tableViewSection headerTitle="UID" id="kdc-iI-3Bd">
401418
<cells>
402419
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="S6s-Qd-Z3i">
403-
<rect key="frame" x="0.0" y="734.5" width="375" height="44"/>
420+
<rect key="frame" x="0.0" y="778.5" width="375" height="44"/>
404421
<autoresizingMask key="autoresizingMask"/>
405422
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="S6s-Qd-Z3i" id="3tB-Th-rk9">
406423
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
@@ -412,7 +429,7 @@
412429
<tableViewSection headerTitle="Phone" id="oSR-wv-pkB">
413430
<cells>
414431
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="yIs-BQ-aU5">
415-
<rect key="frame" x="0.0" y="817.5" width="375" height="44"/>
432+
<rect key="frame" x="0.0" y="861.5" width="375" height="44"/>
416433
<autoresizingMask key="autoresizingMask"/>
417434
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="yIs-BQ-aU5" id="JNr-3n-gTS">
418435
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
@@ -424,14 +441,14 @@
424441
<tableViewSection headerTitle="Provider Access Token" id="TTf-7r-Kld">
425442
<cells>
426443
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" textLabel="NKE-io-hSe" style="IBUITableViewCellStyleDefault" id="BZ9-c2-MUK">
427-
<rect key="frame" x="0.0" y="900.5" width="375" height="44"/>
444+
<rect key="frame" x="0.0" y="944.5" width="375" height="44"/>
428445
<autoresizingMask key="autoresizingMask"/>
429446
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="BZ9-c2-MUK" id="AuA-sR-YEx">
430447
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
431448
<autoresizingMask key="autoresizingMask"/>
432449
<subviews>
433450
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="NKE-io-hSe">
434-
<rect key="frame" x="16" y="0.0" width="343" height="44"/>
451+
<rect key="frame" x="15" y="0.0" width="352" height="44"/>
435452
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
436453
<fontDescription key="fontDescription" type="system" pointSize="16"/>
437454
<nil key="textColor"/>
@@ -445,7 +462,7 @@
445462
<tableViewSection headerTitle="Provider Id Token" id="i6h-Na-zzy">
446463
<cells>
447464
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" textLabel="RB6-Yv-KVG" style="IBUITableViewCellStyleDefault" id="LmG-vd-Xzu">
448-
<rect key="frame" x="0.0" y="983.5" width="375" height="44"/>
465+
<rect key="frame" x="0.0" y="1027.5" width="375" height="44"/>
449466
<autoresizingMask key="autoresizingMask"/>
450467
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="LmG-vd-Xzu" id="b7z-I4-euc">
451468
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>

samples/swift/FirebaseUI-demo-swift/Samples/Auth/FUIAuthViewController.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ enum Providers: Int, RawRepresentable {
3838
case Google
3939
case Facebook
4040
case Twitter
41+
case Apple
4142
case Phone
4243
}
4344

@@ -88,6 +89,9 @@ class FUIAuthViewController: UITableViewController {
8889
self.tableView.selectRow(at: IndexPath(row: Providers.Twitter.rawValue, section: UISections.Providers.rawValue),
8990
animated: false,
9091
scrollPosition: .none)
92+
self.tableView.selectRow(at: IndexPath(row: Providers.Apple.rawValue, section: UISections.Providers.rawValue),
93+
animated: false,
94+
scrollPosition: .none)
9195
self.tableView.selectRow(at: IndexPath(row: Providers.Phone.rawValue, section: UISections.Providers.rawValue),
9296
animated: false,
9397
scrollPosition: .none)
@@ -302,6 +306,12 @@ class FUIAuthViewController: UITableViewController {
302306
"user_friends",
303307
"ads_read"])
304308
: FUIFacebookAuth()
309+
case Providers.Apple.rawValue:
310+
if #available(iOS 13.0, *) {
311+
provider = FUIOAuth.appleAuthProvider()
312+
} else {
313+
provider = nil
314+
}
305315
case Providers.Phone.rawValue:
306316
provider = FUIPhoneAuth(authUI: self.authUI!)
307317
default: provider = nil

0 commit comments

Comments
 (0)