Giter Site home page Giter Site logo

sventiigi / stlocationrequest Goto Github PK

View Code? Open in Web Editor NEW
639.0 18.0 53.0 119.47 MB

Request the Location Services via a 3D 360° flyover MKMapView 🗺

Home Page: https://sventiigi.github.io/STLocationRequest/

License: MIT License

Ruby 4.60% Swift 95.40%
swift 3d-flyover location-services permissions mapview cocoapods carthage

stlocationrequest's Introduction

Logo


STLocationRequest

Swift 5.0 Version Carthage Compatible Platform Documentation Twitter

STLocationRequest is a simple and elegant way to request the users location services at the very first time. The STLocationRequestController shows a beautiful 3D 360° Flyover-MapView bult on top of FlyoverKit with over 25 cities and landmarks.

Preview GIF

Installation

CocoaPods

STLocationRequest is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'STLocationRequest'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

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

github "SvenTiigi/STLocationRequest"

Run carthage update --platform iOS to build the framework and drag the build:

  • STLocationRequest.framework
  • FlyoverKit.framework

into your Xcode project.

On your application targets’ “Build Phases” settings tab, click the “+” icon, choose “New Run Script Phase” and add the Framework paths (for all Frameworks) as mentioned in Carthage Getting started Step 4, 5 and 6

Usage

import STLocationRequest

// Initialize STLocationRequestController with STLocationRequestController.Configuration
let locationRequestController = STLocationRequestController { (config: inout STLocationRequestController.Configuration) in
    config.title.text = "We need your location for some awesome features"
    config.allowButton.title = "Alright"
    config.notNowButton.title = "Not now"
    config.mapView.alpha = 0.9
    config.backgroundColor = UIColor.lightGray
    config.authorizeType = .requestWhenInUseAuthorization
}

// Get notified on STLocationRequestController.Events
locationRequestController.onEvent = { event in
    if case .locationRequestAuthorized = event {
        // Location Request Authorized 🙌
    }
}

// Present STLocationRequestController
locationRequestController.present(onViewController: self)

Please keep in mind that the 3D flyover view will only work on a real iOS device (Read more).

Configuration

The STLocationRequestController can be customized via the the STLocationRequestController.Configuration struct. There are plenty of options available 👨‍💻 More details can be found here

OnEvent

The onEvent function get invoked if an STLocationRequestController.Event occured. Simply set an anonymous function of type (Event) -> Void to evaluate the event.

locationRequestController.onEvent = { (event: STLocationRequestController.Event) in
    switch event {
        case .locationRequestAuthorized:
            break
        case .locationRequestDenied:
            break
        case .notNowButtonTapped:
            break
        case .didPresented:
            break
        case .didDisappear:
            break
    }
}

Info.plist

To perform a location request, define a usage description in your Info.plist file.

STLocationRequestController.Authorization.requestWhenInUseAuthorization

<key>NSLocationWhenInUseUsageDescription</key>
<string>The usage description</string>

STLocationRequestController.Authorization.requestAlwaysAuthorization

<key>NSLocationAlwaysUsageDescription</key>
<string>The usage description</string>

The usage description will be shown in the default iOS location request dialog after the user taps the allow button.

Presenting-Recommendation

The recommended way to present STLocationRequestController is:

if STLocationRequestController.shouldPresentLocationRequestController {
    // Location Services are enabled and authorizationStatus is notDetermined
    // Ready to present STLocationRequestController
    self.presentLocationRequestController()
}

iOS Simulator

Please keep in mind that the 3D flyover view will only work on a real iOS device with at least iOS 9.0 installed (Apple Developer API Reference). A Screenshot taken from an iOS Simulator running a STLocationRequestController visualizes the iOS Simulator behaviour.

iOSSimulatorBehavior

Dependencies

STLocationRequest uses the following libraries.

Contributing

Contributions are very welcome. 🙌 🤓

Example Application

To run the example Application, generate the Frameworks via Carthage first.

$ carthage update --platform iOS
$ open STLocationRequest.xcodeproj

License

STLocationRequest
Copyright (c) 2020 Sven Tiigi <[email protected]>

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.

stlocationrequest's People

Contributors

bryanchan777 avatar giulio92 avatar grodowski avatar oooseun avatar rico237 avatar sventiigi avatar wjiuxing 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stlocationrequest's Issues

Can't close modally presented ViewController any more

Until now I have used STLocationRequest in a "normal" ViewController.
The only thing I changed was presenting the VC modally but now I can't close the VC itself anymore after showing the LocationRequest.

I use
self.navigationController?.dismissViewControllerAnimated(true, completion: nil)
for closing and it's working everywhere fine but not in the VC with the LocationRequest...

Use STLocationRequest in objective-c ViewController

Hello I'm getting this error.

fatal error: unexpectedly found nil while unwrapping an Optional value (lldb)

I have a felling that the storyboard view is not loading but I'm not sure.This is how I try to present the view

STLocationRequestController *request = [[STLocationRequestController alloc] init]; [request setTitle:@"test"]; [request setTitleLabelText:@"test"]; [request setAllowButtonTitle:@"Alright"]; [request setNotNowButtonTitle:@"eded"]; [request setMapViewAlphaValue: 0.9]; [request setBackgroundViewColor: [UIColor lightGrayColor]]; [self presentViewController:request animated:YES completion:nil];

UITapGestureRecognizer doesn't work

I'm using the mapView as the background for my login screen. I added a UITapGestureRecognizer to self.view but it hardly works. The Selector just does: self.view.endEditing(true) yet it only works very rarely after tapping the screen multiple times.

My only assumption is that since the screen is rotating; tap gestures are not always recognized. I tried implementing all different types of gestures and overriding UIGestureRecognizerDelegate methods but nothing seems to work.

Any ideas?

never show 3D scene once click Present STLocationRequestController -> Alright

Hi Sven Tiigi,
Thanks a lot for this awesome app! Would you mind take a look at the issue I have when I build and run it on my iPhone6+?

I build app with Xcode9.2 & I put screen record on youtube: https://youtu.be/7i2Z4zp91To
Xcode debug console shows following error, is this expected because of no 3D flyover data for my GPS location?

I already allowed STLocationRequest to access my location while using the app.

2018-03-03 07:08:29.613910-0800 STLocationRequestExample[2286:581454] Could not inset compass from edges 9
2018-03-03 07:08:29.614784-0800 STLocationRequestExample[2286:581454] Could not inset scale from edge 9
2018-03-03 07:08:29.642869-0800 STLocationRequestExample[2286:581454] Could not inset legal attribution from corner 4
2018-03-03 07:08:29.818637-0800 STLocationRequestExample[2286:581454] Could not inset legal attribution from corner 4
2018-03-03 07:08:30.018142-0800 STLocationRequestExample[2286:581454] Could not inset compass from edges 9
2018-03-03 07:08:30.018310-0800 STLocationRequestExample[2286:581454] Could not inset scale from edge 9
2018-03-03 07:08:30.638770-0800 STLocationRequestExample[2286:581610] Download failed: {x:2623 y:6334 z:14 (2623.6334.14 type: 16 pixel: 2 r2: 920000 Voltaire3D)} Error: Error Domain=GEOErrorDomain Code=-7 "(null)" UserInfo={HTTPStatus=404, NSErrorFailingURLStringKey=https://gspe11-ssl.ls.apple.com/tile?style=16&v=1203&z=14&x=2623&y=6334&sid=1448789466378065446706432234197647015410&accessKey=1520093909_ezmqz9c5nWKP2G61_ETJGJBlfWyYvciaFgB4sJByi2UyeMYVMAhcYOLBlpdmY62QGO77JKk20DxJpPqaKAp8ZlmY8jNaXeN7OY5G5Yfq2SIfwKRsLBiMr7DxJtL1MpokVpcyPZ3Ll9ZjRCccHsQVnp9NokUl%2BZVwzU0aMWQ%3D%3D}
2018-03-03 07:08:30.639438-0800 STLocationRequestExample[2286:581552] Download failed: {x:4822 y:6161 z:14 (4822.6161.14 type: 16 pixel: 2 r2: 260000 Voltaire3D)} Error: Error Domain=GEOErrorDomain Code=-7 "(null)" UserInfo={HTTPStatus=404, NSErrorFailingURLStringKey=https://gspe11-ssl.ls.apple.com/tile?style=16&v=1035&z=14&x=4822&y=6161&sid=1448789466378065446706432234197647015410&accessKey=1520093910_Q90fkWbwsaqZXDsO_Fetx3JZchM%2Bn3YnAs99s3tEvMhUpPJ8xaFafOcdSx%2BLaLKJzuE9uSc3lppshFToECwiQfD%2Fqf9%2BeQIfFmueFKPeW6WjEAKc0l%2F8ztZ7H1u%2FKE14O2G1XigPkqFn8K8U1mwNVlprmD3ugQl0M3%2FvL0w%3D%3D}
2018-03-03 07:08:30.639226-0800 STLocationRequestExample[2286:581620] [VKDefault] Failed to load DTM: 10049 2623 14
2018-03-03 07:08:30.640476-0800 STLocationRequestExample[2286:581620] [VKDefault] Failed to load DTM: 10222 4822 14
Retrieved STLocationRequestController.Event: didPresented
STLocationRequestController did presented
2018-03-03 07:08:35.559640-0800 STLocationRequestExample[2286:581611] Download failed: {x:4821 y:6161 z:14 (4821.6161.14 type: 16 pixel: 2 r2: 260000 Voltaire3D)} Error: Error Domain=GEOErrorDomain Code=-7 "(null)" UserInfo={HTTPStatus=404, NSErrorFailingURLStringKey=https://gspe11-ssl.ls.apple.com/tile?style=16&v=1035&z=14&x=4821&y=6161&sid=1448789466378065446706432234197647015410&accessKey=1520093915_LuvdJ7DpttTeiG5e_v42WPWU%2FXIuCWUWl4PTDKboQZXEKMtmSUZR7QZxXv5CQsKMoxcfOFd5nLAcE3%2F%2FAZA4vwcy9q8pryaHk8BN%2F29ii%2BUE7joCLV7d1%2FfrHKUhj9Ls8ObVj0DUaRg4Z9NhIzm8l1KzUu4MOsCUU81pK4w%3D%3D}
2018-03-03 07:08:35.560459-0800 STLocationRequestExample[2286:581620] [VKDefault] Failed to load DTM: 10222 4821 14
Retrieved STLocationRequestController.Event: locationRequestAuthorized
The user accepted the use of location services
didUpdateLocations UserLocation: Optional(<+37.68481274,-121.87087337> +/- 5.00m (speed 0.00 mps / course -1.00) @ 3/3/18, 7:07:32 AM Pacific Standard Time)
2018-03-03 07:08:52.241496-0800 STLocationRequestExample[2286:581933] Download failed: {x:4823 y:6160 z:14 (4823.6160.14 type: 16 pixel: 2 r2: 260000 Voltaire3D)} Error: Error Domain=GEOErrorDomain Code=-7 "(null)" UserInfo={HTTPStatus=404, NSErrorFailingURLStringKey=https://gspe11-ssl.ls.apple.com/tile?style=16&v=1035&z=14&x=4823&y=6160&sid=1448789466378065446706432234197647015410&accessKey=1520093931_xrU35PRj6DtyWNeh_f66Eu7UtuTstJ4vimk1Rv8zhzE9g8MIr9LFpuuirjUEvolmLjuhVjhfhmbSuAyFaVla2elxEuNuisCsxWgzZwQUDFcmR04KYP3JBBZjm8GOuf7IVIV%2FrljSoWUDcu3NAkX35pvRNX%2F%2B%2BuBPU6bAd9Q%3D%3D}
2018-03-03 07:08:52.241706-0800 STLocationRequestExample[2286:581620] [VKDefault] Failed to load DTM: 10223 4823 14
Retrieved STLocationRequestController.Event: didDisappear
STLocationRequestController did disappear
2018-03-03 07:08:52.378263-0800 STLocationRequestExample[2286:581947] Download failed: {x:77178 y:98571 z:18 (77178.98571.18 type: 15 pixel: 2 text: 2 r2: 260000 Voltaire3D)} Error: Error Domain=GEOErrorDomain Code=-2 "(null)"

Swift 4.2 Support?

The library, and underlying FlyoverKit does not compile with Swift 4.2 with a lot of deprecation issues. Is update to 4.2 is expectable anywhere soon?

using pod with Swift 3.0 project

Hi!
I'm trying to use this cool library in a Swift 3.0 project with pod.
The problem is that when I'm doing pod install "Font-Awesome", 1.5.3 is installed instead of the 1.6.1, so the project doesn't compile because the 1.5.3 code is not written in Swift 3.0

What should I do :) ?

Thanks

Luca.

Compilation errors in STLocationRequestController

Hi,

First let me say that your library looks awesome!
I'm trying to use it in my project but I'm having some problems.

I modified my Podfile to include STLocationRequest:

platform :ios, '8.0'
use_frameworks!

target 'Squirlo' do
pod 'Google/SignIn'
pod 'GoogleMaps'
pod 'STLocationRequest'
end

target 'SquirloTests' do
end

target 'SquirloUITests' do
end

This is the output I'm getting when I'm running pod install:

Updating local specs repositories

CocoaPods 1.0.0 is available.
To update use: `gem install cocoapods`
Until we reach version 1.0 the features of CocoaPods can and will change.
We strongly recommend that you use the latest version at all times.

For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.

Analyzing dependencies
Downloading dependencies
Installing Font-Awesome-Swift (1.4.7)
Using Google (2.0.4)
Using GoogleAppUtilities (1.1.0)
Using GoogleAuthUtilities (2.0.0)
Using GoogleInterchangeUtilities (1.2.0)
Using GoogleMaps (1.13.0)
Using GoogleNetworkingUtilities (1.2.0)
Using GoogleSignIn (3.0.0)
Using GoogleSymbolUtilities (1.1.0)
Using GoogleUtilities (1.3.0)
Installing STLocationRequest (0.2.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 3 dependencies from the Podfile and 11 total pods installed.

The problem is that when I go back to Xcode, I'm getting compilation errors coming from STLocationRequestController. In particular the compilation error I'm getting is for the following line:

self.timer = NSTimer.scheduledTimerWithTimeInterval(15, target: self, selector: #selector(STLocationRequestController.changeRandomFlyOverCity), userInfo: nil, repeats: true)

I can fix that by manually changing the above line to the following:

self.timer = NSTimer.scheduledTimerWithTimeInterval(15, target: self, selector: "changeRandomFlyOverCity", userInfo: nil, repeats: true)

After fixing the above error, I'm trying to use the library but when I'm trying to import STLocationRequest I'm getting an error saying No such module 'STLocationRequest'

What am I doing wrong?

Many thanks,
Alex

not working on IOS 11

Hi there,

It docent work after upgraded to iOS 11.

The popup box with "Alright" is clickable but docent accecpt the selection.

But if pressing " Not now " it goes away as it should.

Allow for Custom Locations

I'd be super if I could specify a custom location.
Currently I have to edit the code and add the new location + GPS info.
Then updates to the code remove that custom location.

Memory leaks

I found memory usage increased every time when a new STLocationRequestController was created and dismissed.
It seems like you didn't invalidate the timer.

Solution:
[viewDidLoad]
// assign the timer to a local var timer: NSTimer?
timer = NSTimer.scheduledTimerWithTimeInterval(15, target: self, selector: "changeRandomFlyOverCity", userInfo: nil, repeats: true)

[viewDidDisappear]
// invalidate the timer and release it.
timer?.invalidate()
timer = nil

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.