iOS App in Swift uses Here Geolocation to make a map sticker that can be added to a snap in Snapchat
Inspired by Location-aware Snapchat stickers with Snap Kit + HERE
You can find great instructions in the post Location-aware Snapchat stickers with Snap Kit + HERE, or follow along below - or do both
Note: If following the instructions in the Here post, an easy to miss detail is using the JavaScript/REST activation rather than the iOS SDK. Use JavaScript/REST
- Sign up for an account on the Snapchat Dev Portal
- Note / copy the value in Development App Info > OAUTH2 CLIENT ID
The Podfile in this repository already contains what is required. See this Snapchat doc. Just run pod install
Edit the Info.plist and add or modify as described below:
Don't forget to remove all of the comments in the info.plist
<key>SCSDKClientId</key>
<string><OAUTH2 CLIENT ID></string> // See the step above in Snapchat Developer Protal
The SCSDKRedirectUrl and the CFBundleURLSchemes are related, as well as the value to place in the Snapchat Developer Portal.
The values can be completely made up. As long as the values match and are unique (see below). For example, if my app is named This Crazy App I could set these values:
- In the Snap Kit Portal, add at least one url to Redirect URLs, in the example this would be thiscrazyapp://myapp
- Add the CFBundleURLSchemes in the info.plist, in the example this would be thiscrazyapp
- Add the SCSDKRedirectUrl in th info.plist, in the example this would be thiscrazyapp://myapp
For more information, see Snapchat Snapkit DIY Docs
<key>LSApplicationQueriesSchemes</key>
<array>
<string>snapchat</string> //add this
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>thiscrazyapp</string> //Should be unique to your app
</array>
<key>CFBundleURLName</key>
<string></string>
</dict>
</array>
<key>SCSDKRedirectUrl</key>
<string>thiscrazyapp://myapp</string> //must match what you add in snapchat dev portal
Set user option for allow location
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location will only be used when app is open</string>
<key>NSLocationUsageDescription</key>
<string>Location is used to create location relevant stickers</string>
The info.plist in this repository is complete and only requires the unique values from your Snap Kit Developer Portal values:
- OAUTH2 CLIENT ID (Development)
- Redirect URLs
Simple. Go to developer.here.com and get a free account. When you get to the point of choosing your SDK, choose JavaScript/REST
Make note of the App ID and the App Code that are displayed after activation.
In the ViewController.swift file, you will see the code below. Replace
func createMapImage() -> UIImage {
struct here {
static var id = "YOUR-APP-ID"
static var code = "YOUR-APP-CODE"
}
Run it on a physical phone so you can use the camera
- Snapchat Snap Kit DIY Docs
- Snapchat Snap Kit Official Documentation
- Location-aware Snapchat stickers with Snap Kit + HERE