snapchat 0.0.2

Snapchat #

Interface with the Snapchat developer kit. Currently supports the Login Kit, for OAuth authentication with Snapchat, and the Creative Kit, for sharing content from your app to Snapchat.

iOS is currently a work in progress.

Installation #

Android #

Edit your project-level build.gradle by adding the snap-kit repository to this block:

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "https://storage.googleapis.com/snap-kit-build/maven"
        }
    }
}

Edit your app-level build.gradle by adding this to the dependencies block:

implementation([
    'com.snapchat.kit.sdk:creative:1.1.4',
    'com.snapchat.kit.sdk:login:1.1.4',
    'com.snapchat.kit.sdk:core:1.1.4'
])

Edit your AndroidManifest.xml:

  • Inside your application tag, add these three fields (inserting your client ID and redirect URL):
<meta-data
    android:name="com.snapchat.kit.sdk.clientId"
    android:value="YOUR_CLIENT_ID" />
<meta-data
    android:name="com.snapchat.kit.sdk.redirectUrl"
    android:value="yourapp://snapchat/oauth2" />
<meta-data
    android:name="com.snapchat.kit.sdk.scopes"
    android:resource="@array/snap_connect_scopes" />
  • Also add this activity tag. You'll need to deconstruct your redirect url into the parts scheme://host path:
<activity
    android:name="com.snapchat.kit.sdk.SnapKitActivity"
    android:launchMode="singleTask">

    <intent-filter>
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <data
            android:scheme="yourapp"
            android:host="snapchat"
            android:path="/oauth2" />
    </intent-filter>

</activity>
  • If you want to use the Creative Kit, add this tag:
<provider
    android:name="android.support.v4.content.FileProvider"
    android:authorities="${applicationId}.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_paths" />
</provider>

Now, create a new file called file_paths.xml inside res/xml with the contents:

<?xml version="1.0" encoding="utf-8"?>
<paths>
    <root-path name="root" path="." />
</paths>

Finally, create a new file called arrays.xml inside res/values with the contents:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="snap_connect_scopes">
        <item>https://auth.snapchat.com/oauth2/api/user.bitmoji.avatar</item>
        <item>https://auth.snapchat.com/oauth2/api/user.display_name</item>
        <item>https://auth.snapchat.com/oauth2/api/user.external_id</item>
    </string-array>
</resources>

iOS #

Coming soon.

Usage #

// Initialize the plugin before using it
var snapchat = SnapchatPlugin();
await snapchat.init();

// Make sure that the user has Snapchat installed
assert await snapchat.isSnapchatInstalled();

// Use the Login Kit to authenticate the user
SnapchatUser user = await snapchat.login();

// Get the cached user
user = snapchat.loggedInUser;
// If there is a cached user, snapchat.login() will automatically return it

// Share an image to Snapchat
await snapchat.send(
  SnapMediaType.Photo,
  path: '/path/to/image.png', // or jpg
);

// Share a video with a caption on it
await snapchat.send(
  SnapMediaType.Video,
  path: '/path/to/video.mp4',
  caption: 'This text can be edited by the user in the app and will appear on top of the video',
);

// Let the user take a photo/video but put a sticker on it
await snapchat.send(
  SnapMediaType.Live,
  sticker: SnapchatSticker(
    '/path/to/image.png',
    x: 0.5, // Percentage of width/height
    y: 0.5,
    width: 50,
    height: 50,
    rotation: 30 // degrees clockwise
    // x, y, width, height, and rotation are all optional
  ),
);


// Log out
await snapchat.logout();

0.0.1 #

  • TODO: Describe initial release.

example/README.md

snapchat_example #

Demonstrates how to use the snapchat plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  snapchat: ^0.0.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:snapchat/snapchat.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
48
Learn more about scoring.

We analyzed this package on Aug 22, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
shared_preferences ^0.5.2 0.5.3+4
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test