All Projects → deivitaka → GPhotos

deivitaka / GPhotos

Licence: MIT license
A wrapper around the Google Photos API.

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to GPhotos

ArchiverForGooglePhotos
A tool to maintain an archive/mirror of your Google Photos library for backup purposes.
Stars: ✭ 104 (+395.24%)
Mutual labels:  google-photos, google-photos-api
GPhotoApp
This is a GAS library for retrieving and creating the albums and media items using Google Photo API using Google Apps Script (GAS).
Stars: ✭ 25 (+19.05%)
Mutual labels:  google-photos, google-photos-api
IBLayoutConstraint
📏 Configure constraints for each device in Interface Builder with IBLayoutConstraint.
Stars: ✭ 24 (+14.29%)
Mutual labels:  swift5
iOSUtilitiesSource
IOS Utilities Library for Swift
Stars: ✭ 46 (+119.05%)
Mutual labels:  swift5
Table
CLI tables in Swift
Stars: ✭ 53 (+152.38%)
Mutual labels:  swift5
Teller-iOS
iOS library that manages your app's cached data with ease.
Stars: ✭ 12 (-42.86%)
Mutual labels:  swift5
DTContainerController
A Swift container view controller to handle transitioning to a different child view controller.
Stars: ✭ 20 (-4.76%)
Mutual labels:  swift5
MMAdvertScrollView
一个简单、轻量级的swift版公告轮播框架
Stars: ✭ 42 (+100%)
Mutual labels:  swift5
PagedLists
Paginated UITableView and UICollectionViews for iOS.
Stars: ✭ 69 (+228.57%)
Mutual labels:  swift5
BadgeControl
Badge view with controller written in Swift 5.0
Stars: ✭ 53 (+152.38%)
Mutual labels:  swift5
Windows11
💻 Windows 11 in SwiftUI.
Stars: ✭ 177 (+742.86%)
Mutual labels:  swift5
photos
"Fx Fotos" is an opensource gallery app in react native with the same smoothness and features of Google Photos and Apple Photos. It is backend gnostic and connects to decentralized backends like "box", "Dfinity", "Filecoin" and "Crust".
Stars: ✭ 620 (+2852.38%)
Mutual labels:  google-photos
CameraButton
No description or website provided.
Stars: ✭ 31 (+47.62%)
Mutual labels:  swift5
Match3Kit
Library for simple Match3 games.
Stars: ✭ 38 (+80.95%)
Mutual labels:  swift5
YRipple
iOS Ripple Effect, Xcode10 and Swift5 available
Stars: ✭ 18 (-14.29%)
Mutual labels:  swift5
swift-starter-kit
Swift Starter Kit with Firebase & Facebook Login Onboarding
Stars: ✭ 105 (+400%)
Mutual labels:  swift5
UberCarAnimation
This app is for animating a car like uber from one position to another with preserving angle and smooth animation
Stars: ✭ 53 (+152.38%)
Mutual labels:  swift5
Swift-FFDB
a Object/Relational Mapping (ORM) support to iOS and MacOS .Since SwiftFFDB is build on top of FMDB.
Stars: ✭ 22 (+4.76%)
Mutual labels:  swift5
skillbox
Выполненные и принятые домашние задания, а также другие материалы, которые могут помочь в обучении
Stars: ✭ 32 (+52.38%)
Mutual labels:  swift5
PixelCrop
A Crop library like Google Photos
Stars: ✭ 52 (+147.62%)
Mutual labels:  google-photos

GPhotos

CI Status Version License Platform

I wanted to consume the Google Photos API in Swift but at the time of writing there is no framework that does it in a simple way.

So why not share my own take?

List of implemented methods:

  • Authentication

    • Auto-refresh token
    • Auto-request authorization
  • Albums

    • addEnrichment - Adds an enrichment at a specified position in a defined album.
    • batchAddMediaItems - Adds one or more media items in a user's Google Photos library to an album.
    • batchRemoveMediaItems - Removes one or more media items from a specified album.
    • create - Creates an album in a user's Google Photos library.
    • get - Returns the album based on the specified albumId.
    • list - Lists all albums shown to a user in the Albums tab of the Google Photos app.
    • share - Marks an album as shared and accessible to other users.
    • unshare - Marks a previously shared album as private.
  • Shared albums

    • get - Returns the album based on the specified shareToken.
    • join - Joins a shared album on behalf of the Google Photos user.
    • leave - Leaves a previously-joined shared album on behalf of the Google Photos user.
    • list - Lists all shared albums available in the Sharing tab of the user's Google Photos app.
  • MediaItems

    • batchCreate - Creates one or more media items in a user's Google Photos library.
    • batchGet - Returns the list of media items for the specified media item identifiers.
    • get - Returns the media item for the specified media item identifier.
    • list - List all media items from a user's Google Photos library.
    • search - Searches for media items in a user's Google Photos library.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

To install through CocoaPods add pod 'GPhotos' to your Podfile and run pod install.

Setup

  • Setup a OAuth 2.0 client ID as described here, download the .plist file and add it to the project.

  • In AppDelegate.swift configure GPhotos when the application finishes launching

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    var config = Config()
    config.printLogs = false
    GPhotos.initialize(with: config)
    // Other configs
}
  • To handle redirects during the authorization process add or edit the following method.
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    let gphotosHandled = GPhotos.continueAuthorizationFlow(with: url)
    // other app links
    return gphotosHandled
}

Usage

Authentication

  • GPhotos.isAuthorized will return true if a user is already authorized.

  • GPhotos.logout() clears the session information and invalidates any token saved.

  • GPhotos.authorize(with scopes:) by default starts the authentication process with openid scope. Will be executed only if there are new scopes. As per Google recommendation, you should gradually add scopes when you need to use them, not on the first run. The method will return a boolean indicating the success status, and an error if any.

  • GPhotos.switchAccount(with scopes:) by default starts the authentication process with openid scope. Will ignore current authentication scopes. The method will return a boolean indicating the success status, and an error if any.

Photos Api

Save an instance of GPhotosApi to be able to use pagination between different features.

Albums

create

  • create(album:) returns the newly created album object

list

  • list() loads sequential pages of items every time it is called.
  • reloadList() loads always the first page.

get

  • get(id:) returns the Album for the provided id.

sharing

  • share(id:options:) shares an album with the provided id with possible options and returns the ShareInfo of the album.
  • unshare(id:) returns a boolean indicating the success status.

enrichments

  • addEnrichment(id:enrichment:position)

media items

Adding or removing items from an album only requires the set of media items ids.

  • addMediaItems(id:mediaIds:)
  • removeMediaItems(id:mediaIds:)

MediaItems

list

  • list() and reloadList() have the same use as in Albums

get

  • get(id:) returns the MediaItem for the provided id.
  • getBatch(ids:) returns the MediaItems for the provided array of ids.

search

  • search(with request:) loads sequential pages of items every time it is called. Results are based on filters in the request. If no filters are applied it will return the same results as list()
  • reloadSearch(with request:) loads always the first page.

batchCreate

  • upload(images:) takes an array of UIImage and uploads them one by one to the user's library. These uploads will count towards storage in the user's Google Account.

SharedAlbums

get

  • get(token:) returns the details of the shared album.

joining

  • join(token:) and leave(token:) take the sharing token as argument and either join or leave the shared album if the token is correct.

list

  • list() and reloadList() have the same use as in Albums

License

GPhotos is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].