Discord Social SDK
Loading...
Searching...
No Matches
Mobile Setup

Mobile Setup

The Discord Social SDK provides experimental support for iOS and Android mobile applications as a preview. To set it up in your project, there's a few things you need to do, depending on the engine or language you're using.

Unity

Please follow the PC development guide for Unity for general setup instructions. There are a few mobile-specific options you'll need to configure as well:

iOS

  • To enable discordpp::Client::Authorize() support, you'll need to configure a callback URL scheme in your project settings. Open the project settings via Edit -> Project Settings... and navigate to the Player section. In the iOS tab, under Other Settings, locate the Supported URL Schemes option and add discord-<YOURAPPID> to the list. For example, if the application ID in the Discord developer portal is 123456, you'll add discord-123456 to the list.
  • In the same settings page, you should set "Microphone Usage Description" to a valid description to enable voice support. This string will be displayed by the operating system when microphone permissions are requested.
  • To enable voice support while your game is backgrounded, you'll need to edit the Info.plist for your project to enable the appropriate background modes. A build postprocessor is supplied in the Unity sample project that you may copy into your own project, located at Assets/Scripts/Editor/VoicePostBuildProcessor.cs.

Android

  • discordpp::Client::Authorize() requires an activity with a custom URL scheme to be added to your application manifest. An example build processor is provided in the sample project at Assets/Scripts/Editor/AndroidPostBuildProcessor.cs. The documentation for the Authorize method provides further details if you'd like to configure this yourself instead of using the sample code.
  • Authorize also requires that you add androidx.browser as a Gradle dependency. If you use Google External Dependency Manager in your project, a suitable dependencies XML file is provided as part of the plugin, otherwise you will need to set this up manually.

Android Permissions

The Android SDK uses the following permissions:

  • android.permission.INTERNET
  • android.permission.RECORD_AUDIO
  • android.permission.FOREGROUND_SERVICE
  • android.permission.FOREGROUND_SERVICE_MICROPHONE
  • android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK
  • android.permission.MODIFY_AUDIO_SETTINGS
  • android.permission.BLUETOOTH (SDK <= 30)
  • android.permission.BLUETOOTH_CONNECT (SDK >= 31)

If your application does not use voice, you may remove all permissions except INTERNET using the tools:node="remove" attribute in your AndroidManifest.xml.

Standalone

The Social SDK may be used as a C++ library in a standard iOS or Android project. To create a project which includes the SDK, follow the steps below for your platform of choice.

iOS

  1. Create an Objective-C iOS project.
  2. Add discord_partner_sdk.xcframework to your project and set your project settings as follows:
  3. Add the xcframework to Build Phases -> Link Binary with Libraries if needed
  4. In the General tab, under Frameworks, Libraries and Embedded Content, set discord_partner_sdk.xcframework to Embed & Sign
  5. To maintain voice connectivity while backgrounded, set background audio modes in your Info.plist using the Signing & Capabilities tab. See Configuring your app for Media Playback for instructions; you should select Audio, AirPlay, and Picture in Picture, not Voice over IP.
  6. To enable discordpp::Client::Authorize() support you must register the appropriate URL scheme in your Info.plist. It should be called discord-YOURAPPID, e.g. if your app ID in the Discord developer portal is 123456, you should register a URL scheme called discord-123456
  7. Include the headers in a C++ or ObjC++ (.mm) source file via #include <discord_partner_sdk/discordpp.h>. Note that in exactly one file in your codebase, you should define #define DISCORDPP_IMPLEMENTATION before including this header to expand necessary implementation code into your project.
  8. In your main game loop, make sure you call discordpp::RunCallbacks().

Android

  1. Create Android game project based on the Game Activity (C++) template.
  2. Add discord_partner_sdk.aar as a dependency in your Gradle project. For example, add it to a directory called app/libs and then in your app/build.gradle, add implementation files("libs/discord_partner_sdk.aar") to your dependencies section.
  3. Ensure prefab is enabled in your Gradle build. See Native Dependencies in AARs for details on how this works.
  4. Add find_package(discord_partner_sdk REQUIRED CONFIG) to your CMakeLists.txt
  5. Add target_link_libraries(your_target discord_partner_sdk::discord_partner_sdk) to link Discord Social SDK
  6. Include the discordpp header via #include "discordpp.h". Note that in exactly one file in your codebase, you should define #define DISCORDPP_IMPLEMENTATION before including this header to expand necessary implementation code into your project.
  7. In the onCreate method for your main activity, call com.discord.socialsdk.DiscordSocialSdkInit.setEngineActivity(this).
  8. In the main loop of the C++ activity, make sure you call discordpp::RunCallbacks().

To support Authorize():

  1. Add androidx.browser dependency to your project (version 1.8 or later)
  2. Add the appropriate AndroidManifest.xml activity registration, see discordpp::Client::Authorize() for details.