Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snapchat #55

Open
wants to merge 16 commits into
base: 1.4_update
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Login Kit Sample Apps

- [Sample iOS App](ios)
- [Sample Android App](android)
- [Sample iOS App](ios)
- [Sample Android App](android)
- [Sample React Native](react-native)
51 changes: 20 additions & 31 deletions ios/LoginKitSample/Classes/LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,24 @@ extension LoginViewController {
}

fileprivate func displayProfile() {
let successBlock = { (response: [AnyHashable: Any]?) in
guard let response = response as? [String: Any],
let data = response["data"] as? [String: Any],
let me = data["me"] as? [String: Any],
let displayName = me["displayName"] as? String,
let bitmoji = me["bitmoji"] as? [String: Any],
let avatar = bitmoji["avatar"] as? String else {
return
}

// Needs to be on the main thread to control the UI.
DispatchQueue.main.async {
self.loadAndDisplayAvatar(url: URL(string: avatar))
self.nameLabel?.text = displayName
}
}

let failureBlock = { (error: Error?, success: Bool) in
if let error = error {
print(String.init(format: "Failed to fetch user data. Details: %@", error.localizedDescription))
}
}

let queryString = "{me{externalId, displayName, bitmoji{avatar}}}"
SCSDKLoginClient.fetchUserData(withQuery: queryString,
variables: nil,
success: successBlock,
failure: failureBlock)
let builder = SCSDKUserDataQueryBuilder().withDisplayName().withBitmojiTwoDAvatarUrl()
SCSDKLoginClient.fetchUserData(
with: builder.build(),
success: { (userData, errors) in
let displayName = userData?.displayName ?? ""
let avatar = userData?.bitmojiTwoDAvatarUrl ?? ""

// Needs to be on the main thread to control the UI.
DispatchQueue.main.async {
self.loadAndDisplayAvatar(url: URL(string: avatar))
self.nameLabel?.text = displayName
}
},
failure: { (error: Error?, isUserLoggedOut: Bool) in
if let error = error {
print(String.init(format: "Failed to fetch user data. Details: %@", error.localizedDescription))
}
})
}

fileprivate func loadAndDisplayAvatar(url: URL?) {
Expand Down Expand Up @@ -119,9 +109,8 @@ extension LoginViewController {
}

@IBAction func logoutButtonDidTap(_ sender: UIBarButtonItem) {
SCSDKLoginClient.unlinkAllSessions { (success: Bool) in
self.displayForLogoutState()
}
SCSDKLoginClient.clearToken()
self.displayForLogoutState()
}
}

Expand Down
2 changes: 1 addition & 1 deletion ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ platform :ios, '12.0'
use_frameworks!

target 'LoginKitSample' do
pod 'SnapSDK', '> 1.3', :subspecs => ['SCSDKLoginKit']
pod 'SnapSDK', '2.5.0', :subspecs => ['SCSDKLoginKit']
end

target 'LoginKitSampleTests' do
Expand Down
14 changes: 8 additions & 6 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
PODS:
- SnapSDK/SCSDKLoginKit (1.3.1)
- SnapSDK/SCSDKCoreKit (2.4.0)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- SnapSDK/SCSDKLoginKit (2.4.0):
- SnapSDK/SCSDKCoreKit

DEPENDENCIES:
- SnapSDK/SCSDKLoginKit (> 1.3)
- SnapSDK/SCSDKLoginKit (= 2.4.0)

SPEC REPOS:
https://github.com/cocoapods/specs.git:
trunk:
- SnapSDK

SPEC CHECKSUMS:
SnapSDK: be510aaabbfa7ab0142b53770f2e79c6c6b363e6
SnapSDK: e832716ff024b17b448f9bca5feeac5a3daed3ff

PODFILE CHECKSUM: b1abc23cbe49d9db7d93e95081b99dbe323bd506
PODFILE CHECKSUM: 954250a1065127ba5e258c68f9ce651a3173eedd

COCOAPODS: 1.6.1
COCOAPODS: 1.11.3
14 changes: 8 additions & 6 deletions ios/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading