Giter Club home page Giter Club logo

unsplash-photopicker-ios's Introduction

Unsplash Photo Picker for iOS

CocoaPods Compatible SPM Compatible Carthage Compatible Platform License

UnsplashPhotoPicker is an iOS UI component that allows you to quickly search the Unsplash library for free high-quality photos with just a few lines of code.

Android photo picker here.

Unsplash Photo Picker for iOS preview

Table of Contents

Description

UnsplashPhotoPicker is a view controller. You present it to offer your users to select one or multiple photos from Unsplash. Once they have selected photos, the view controller returns UnsplashPhoto objects that you can use in your app.

Requirements

⚠️ UnsplashPhotoPicker is not compatible with Objective-C.

Installation

Swift Package Manager

To integrate UnsplashPhotoPicker into your Xcode project using Swift Package Manager, open dependency manager through File > Swift Packages > Add Package Dependency....

and insert repository URL:

https://github.com/unsplash/unsplash-photopicker-ios.git

To add dependency in your own package, just specify it in dependencies of your Package.swift:

.package(
  name: "UnsplashPhotoPicker",
  url: "https://github.com/unsplash/unsplash-photopicker-ios.git",
  .upToNextMajor(from: "1.3.0")
)

Carthage

To integrate UnsplashPhotoPicker into your Xcode project using Carthage, specify it in your Cartfile:

github "unsplash/unsplash-photopicker-ios" ~> 1.3

Run carthage update to build the framework and drag the built UnsplashPhotoPicker.framework into your Xcode project.

CocoaPods

To integrate UnsplashPhotoPicker into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '12.1'
use_frameworks!

target '<Your Target Name>' do
    pod 'UnsplashPhotoPicker', '~> 1.3'
end

Then run pod install.

Git submodule

If you prefer not to use any of the aforementioned dependency managers, you can integrate UnsplashPhotoPicker into your project manually as a git submodule by running the following command in the project's folder:

$ git submodule add https://github.com/unsplash/unsplash-photopicker-ios.git

Drag the UnsplashPhotoPicker.xcodeproj file into your Xcode project, then drag the UnsplashPhotoPicker.framework to your target's "Embedded Binaries".

Usage

❗️Before you get started, you need to register as a developer on our Developer portal. Once registered, create a new app to get an Access Key and a Secret Key.

Configuration

The UnsplashPhotoPicker is configured with an instance of UnsplashPhotoPickerConfiguration:

UnsplashPhotoPickerConfiguration(accessKey: String,
                                 secretKey: String,
                                 query: String,
                                 allowsMultipleSelection: Bool,
                                 memoryCapacity: Int,
                                 diskCapacity: Int)
Property Type Optional/Required Default
accessKey String Required N/A
secretKey String Required N/A
query String Optional nil
allowsMultipleSelection Bool Optional false
memoryCapacity Int Optional 50
diskCapacity Int Optional 100
contentFilterLevel ContentFilterLevel Optional .low

Presenting

UnsplashPhotoPicker is a subclass of UINavigationController. We recommend that you present it modally or as a popover on iPad. Before presenting it, you need to implement the UnsplashPhotoPickerDelegate protocol, and use the photoPickerDelegate property to get the results.

protocol UnsplashPhotoPickerDelegate: class {
  func unsplashPhotoPicker(_ photoPicker: UnsplashPhotoPicker, didSelectPhotos photos: [UnsplashPhoto])
  func unsplashPhotoPickerDidCancel(_ photoPicker: UnsplashPhotoPicker)
}

Using the results

UnsplashPhotoPicker returns an array of UnsplashPhoto objects. See UnsplashPhoto.swift for more details.

License

MIT License

Copyright (c) 2018-2022 Unsplash Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

unsplash-photopicker-ios's People

Contributors

balavor avatar damiancarrillo avatar lekom avatar leonid117 avatar lisindima avatar nicol3a avatar ocollet avatar pocketpixels avatar pzmudzinski avatar zsbee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unsplash-photopicker-ios's Issues

there is no SQL cache DB located at unsplash//Cache.db

When presenting the UnsplashPhotoPicker as described below, my application is throwing hundreds of these errors in the console. Any thoughts on what could be causing them and how to fix it?

[logging-persist] cannot open file at line 44515 of [02c344acea]
[logging-persist] os_unix.c:44516: (0) open(//unsplash//Cache.db) - Undefined error: 0
NetworkStorageDB:_openDBReadConnections: failed to open read connection to DB @ unsplash//Cache.db. Error=14. Cause=unable to open database file
The read-connection to the DB=unsplash//Cache.db is NOT valid. Unable to determine schema version.
[logging-persist] cannot open file at line 44515 of [02c344acea]
[logging-persist] os_unix.c:44516: (0) open(//unsplash//Cache.db) - Undefined error: 0
NetworkStorageDB:_openDBWriteConnections: failed to open write connection to DB @ unsplash//Cache.db. Error=14. Cause=unable to open database file
DEBUG: there is no SQL cache DB located at unsplash//Cache.db.
DEBUG: there is no SQL cache DB located at unsplash//Cache.db-shm.
DEBUG: there is no SQL cache DB located at unsplash//Cache.db-wal.
[logging] API call with unopened database connection pointer
[logging] misuse at line 130558 of [02c344acea]

images do not load

Images do not load.

I just downloaded the example project and added my keys. I am sure my keys are valid because i get search results.

here is a screenshot of the issue : https://imgur.com/x65dqrP

Add the ability to pass a search string when instantiating the photo picker

Some use cases can require to show photos around a specific search, and not allow users to search themselves.

We can add a query: String? parameter to UnsplashPhotoPickerConfiguration.

  • If the value is nil, we keep the current behaviour.
  • If the value contains a string, the photo picker performs the search right away, and the search bar is not visible.

API misuse

When using this Library, everything seems to work fine, but I'm getting dozens of messages like this on the console:

2020-11-17 09:57:18.377493+0100 MyProject[17854:197368] [logging] misuse at line 130558 of [02c344acea]
2020-11-17 09:57:18.377694+0100 MyProject[17854:197368] [logging] API call with unopened database connection pointer

Should I worry about having problems with Unsplash? They say they can ban my account if I'm misusing the API

Invalid exclude '.../UnsplashPhotoPicker.h': File not found.

Since Xcode 13 I'm getting the following warning:

  • Invalid Exclude 'Users/abc/Library/Developer/Xcode/DerivedData/app-doylkpssjtiwgacyfgzwbtlcseds/SourcePackages/checkouts/unsplash-photopicker-ios/UnsplashPhotoPicker/UnsplashPhotoPicker/UnsplashPhotoPicker.h': File not found.

How can I resolve this warning? I'm using v1.2.0.

SPM Support

Hey there,

We are upgrading our dependency manager to SPM. We would love support for Unsplash as well. Thanks!

Photo Picker Configuration on Obj-C

Hello,
maybe I'm missing something, but I'm trying to integrate the Unsplash Photo Picker in my native app written in Objective C.

I've imported the framework using CocoaPods and that creates the UnsplashPhotoPicker.h header in my project.
I can import it in my UIViewController, but I am unable to configurate the picker with the relevant information (accessKey, secretKey, etc.).
In Objective C it only allows me to call the basic initialization
UnsplashPhotoPicker *picker = [[UnsplashPhotoPicker alloc] init];
but it then throws an error on this line, saying
UnsplashPhotoPicker/UnsplashPhotoPicker.swift:31: Fatal error: Use of unimplemented initializer 'init(nibName:bundle:)' for class 'UnsplashPhotoPicker.UnsplashPhotoPicker'

I don't know how to proceed. What am I missing here?
I don't know how to correctly call the configuration method using Objective C.

@ocollet any suggestions on how to fix it?

Thanks

author clickable link

from https://help.unsplash.com/en/articles/2511315-guideline-attribution

When displaying a photo from Unsplash, your application must attribute Unsplash, the Unsplash photographer, and contain a link back to their Unsplash profile. All links back to Unsplash should use utm parameters in the form of ?utm_source=your_app_name&utm_medium=referral

this sdk does not support this behavior. does this conflict with the documentation? Is it possible to get full access to the api using the official sdk?

Server Error

Hi. I use unsplash IOS sdk. At he beginning
ServerError
it works very well but from some time I noticed that on searching (basic words as firework green camera ) very often appear "Server error" message.
And it very strange but then I tried next day some of them work and API returned a list of images.

Do you know what could be the problem?
Thanks

Could not load NIB with name 'PhotoView'

After presenting the picker receive this error:

libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/g.goncharik/Library/Developer/CoreSimulator/Devices/A1D0205D-FE16-45D6-8742-F235CF7A6BE5/data/Containers/Bundle/Application/9A548FD9-68AA-41E0-B149-0D7C976BDF68/MusicApp.app> (loaded)' with name 'PhotoView''
terminating with uncaught exception of type NSException
CoreSimulator 732.18.6 - Device: iPhone 12 (A1D0205D-FE16-45D6-8742-F235CF7A6BE5) - Runtime: iOS 14.3 (18C61) - DeviceType: iPhone 12

Dark mode support

Hi, tell me please, would you add dark mode support or I should manage it in my code? Thanks

Getting author urls

Hi, I am using your sdk, but I have some problems with getting photo's author links. As I understand from API, I am getting it in format

{ "id": "pXhwzz1JtQU", "updated_at": "2016-07-10T11:00:01-05:00", "username": "jimmyexample", "name": "James Example", "first_name": "James", "last_name": "Example", "instagram_username": "instantgrammer", "twitter_username": "jimmy", "portfolio_url": null, "bio": "The user's bio", "location": "Montreal, Qc", "total_likes": 20, "total_photos": 10, "total_collections": 5, "followed_by_user": false, "followers_count": 300, "following_count": 25, "downloads": 225974, "profile_image": { "small": "https://images.unsplash.com/face-springmorning.jpg?q=80&fm=jpg&crop=faces&fit=crop&h=32&w=32", "medium": "https://images.unsplash.com/face-springmorning.jpg?q=80&fm=jpg&crop=faces&fit=crop&h=64&w=64", "large": "https://images.unsplash.com/face-springmorning.jpg?q=80&fm=jpg&crop=faces&fit=crop&h=128&w=128" }, "badge": { "title": "Book contributor", "primary": true, "slug": "book-contributor", "link": "https://book.unsplash.com" }, "links": { "self": "https://api.unsplash.com/users/jimmyexample", "html": "https://unsplash.com/jimmyexample", "photos": "https://api.unsplash.com/users/jimmyexample/photos", "likes": "https://api.unsplash.com/users/jimmyexample/likes", "portfolio": "https://api.unsplash.com/users/jimmyexample/portfolio" } }

So I need to add coding field "link" to UnsplashUser, but I am getting error "typeMismatch".
Please help me, and I will be very glad if you add this to your sdk, because this is necessary for following Unsplash guidelines. Or maybe there are other ways of solving this problem.
Thanks.

SERVER ERROR DUE TO SCHEMA CHANGE

Since today we are receiving Server Error when our users open the Unplashphoto picker modal. This is because the server returns the Unsplash.links dictionary in a new form for the getCollection requests. (Not for every but for some photos), The Codable decoding fails, as alternative_html is a dictionary instead of the URL.

Can you @ocollet please as a first reach out to the server team to revert any change that is causing this? Then a second update the Unsplasphoto model not to accept dictionary bot specific models? :)

Client code

public enum LinkKind: String, Codable {
        case own = "self"
        case html
        case download
        case downloadLocation = "download_location"
    }

public let links: [LinkKind: URL]

Server response of the dictionary

"links":
        {
            "self": "https://api.unsplash.com/photos/a-mountain-range-covered-in-snow-with-mountains-in-the-background--Sqw0ZRsdh8",
            "html": "https://unsplash.com/photos/a-mountain-range-covered-in-snow-with-mountains-in-the-background--Sqw0ZRsdh8",
            "alternative_html":
            {
                "en": "https://unsplash.com/photos/a-mountain-range-covered-in-snow-with-mountains-in-the-background--Sqw0ZRsdh8",
                "es": "https://unsplash.com/es/fotos/una-cadena-montanosa-cubierta-de-nieve-con-montanas-al-fondo--Sqw0ZRsdh8",
                "ja": "https://unsplash.com/ja/%E5%86%99%E7%9C%9F/%E9%9B%AA%E3%81%AB%E8%A6%86%E3%82%8F%E3%82%8C%E3%81%9F%E5%B1%B1%E8%84%88%E3%82%92%E8%83%8C%E6%99%AF%E3%81%AB%E5%B1%B1%E3%80%85--Sqw0ZRsdh8",
                "fr": "https://unsplash.com/fr/photos/une-chaine-de-montagnes-recouverte-de-neige-avec-des-montagnes-en-arriere-plan--Sqw0ZRsdh8",
                "it": "https://unsplash.com/it/foto/una-catena-montuosa-coperta-di-neve-con-montagne-sullo-sfondo--Sqw0ZRsdh8",
                "ko": "https://unsplash.com/ko/%EC%82%AC%EC%A7%84/%EC%82%B0%EC%9D%84-%EB%B0%B0%EA%B2%BD%EC%9C%BC%EB%A1%9C-%EB%88%88%EC%9C%BC%EB%A1%9C-%EB%8D%AE%EC%9D%B8-%EC%82%B0%EB%A7%A5--Sqw0ZRsdh8",
                "de": "https://unsplash.com/de/fotos/eine-schneebedeckte-bergkette-mit-bergen-im-hintergrund--Sqw0ZRsdh8",
                "pt": "https://unsplash.com/pt-br/fotografias/uma-cordilheira-coberta-de-neve-com-montanhas-ao-fundo--Sqw0ZRsdh8"
            },
            "download": "https://unsplash.com/photos/-Sqw0ZRsdh8/download?ixid=M3wxNDIyNzR8MHwxfGNvbGxlY3Rpb258Mjl8MzE3MDk5fHx8fHwyfHwxNzA5ODE5MzY1fA",
            "download_location": "https://api.unsplash.com/photos/-Sqw0ZRsdh8/download?ixid=M3wxNDIyNzR8MHwxfGNvbGxlY3Rpb258Mjl8MzE3MDk5fHx8fHwyfHwxNzA5ODE5MzY1fA"
        },

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.