05/15/2024 15:19:45

Twitter Function description of the System channel

I. Overview

I. Overview

Twitter is a US social app which provides social networking and microblogging services to users. Its main users are in Europe and America.


1. Twitter officially no longer maintains its SDK. Please see Twitter official announcement
2. Starting from MSDK5.9 version, Twitter login module which encapsulates the web version avoids the risk that Twitter SDK is no longer maintained.
3. Twitter's own SDK uses UIWebview, which may be rejected by Apple for review. Starting from MSDK5.10.001 version, the iOS Twitter channel only supports web login and eliminates Twitter SDK.

II. Developer Platform Configuration

II. Developer Platform Configuratio

1) Sign up for a Twitter account

Please go to Twitter's official website to register an account: twitter.com, and follow the prompts to complete account authentication (Email or mobile phone authentication).

To create an application, you need to add an overseas mobile phone number; otherwise, an error will be reported.

2) Create App

After you have an account, you can create your own app in the Developer Center: apps.twitter.com

 Create App

3) Get API Key and Secret

In the management console's Keys and Access Tokens menu, find

Get App Key

4) Callback URLs configuration

Callback URLs requires to be filled in with Scheme for Android and iOS:

  • Android: filled in with a fixed value twittersdk: //
  • iOS: filled in with twitterkit-{Twitter_Key}://. {Twitter_Key} needs to be replaced with the game's Twitter Key

Set Callback URL

[warning] Caution This must be filled in correctly, otherwise, a login exception may occur at the launch of webpage login if the phone is not installed with Twitter

5) permission configuration

In the management console's Permissions page, verify that the Read and Write permission is included

Set Permissions

6) Configure MSDK backend

Please go to MSDK management console to make the backend configuration. Please contact RTX: hirryli

III. Project Configuration

III. Project Configuration

3.1 Android

1) Configure Twitter App Key and Secret

Configure Twitter in Android project configuration file assets/MSDKConfig.ini as follows:

  [Twitter channel configuration]   

    TWITTER_KEY = {Your_Twitter_key}
    TWITTER_SECRET = {Your_Twitter_secret}
  • Your_Encrypted_Twitter_Key needs to be replaced with the encrypted ciphertext of API Key in the console
  • Your_Encrypted_Twitter_Secret needs to be replaced with the encrypted ciphertext of API Secret in the console

[warning] Caution

  1. Starting from MSDK5.9 version, Twitter configuration distinguishes both ends and no longer uses TWITTER_KEY and TWITTER_SECRET; and Android uses TWITTER_KEY_ANDROID and TWITTER_SECRET_ANDROID instead.
  2. Starting from MSDK5.9 version, Twitter's Android configuration no longer uses plaintext, and the game needs to go to the MSDK console ( Feiying System-My Game-Login Information-Joint Debugging Environment Configuration-Twitter) to configure the signature information (after clicking the "Publish to the joint debugging environment" button and then entering the encryption page, you can see the ciphertext encrypted with the default signature; otherwise, you need to manually enter the signature), and get the encrypted Key and Secret and replace Your_Encrypted_Twitter_Key and Your_Encrypted_Twitter_Secret with the obtained ciphertext.
  3. If the game uses different signatures on different channel stores, it should make sure that the ciphertext encrypted by the corresponding signature is used when the channel is packaged. The MSDK Twitter Android plugin package of MSDK 5.10 and higher versions supports multiple Twitter ciphertext configurations. Feiying also supports to configure multiple signatures. On Feiying, you can get the ciphertext encrypted with multiple different signatures.

In MSDK 5.10 and higher versions, Twitter Android supports multiple ciphertext configurations (use different signatures to encrypt Twitter Key and Secret), and separate them with ','. Note that multiple Keys and Secrets must correspond one-to-one in order. Make the following configuration in Android project assets/MSDKConfig.ini:

  [Twitter channel configuration]
    TWITTER_KEY_ANDROID = {Your_Encrypted_Twitter_Key_1,Your_Encrypted_Twitter_Key_2}
    TWITTER_SECRET_ANDROID = {Your_Encrypted_Twitter_Secret_1,Your_Encrypted_Twitter_Secret_2}
  • Your_Encrypted_Twitter_Key_1 and Your_Encrypted_Twitter_Secret_1 need to be replaced with the ciphertexts formed after using signature 1 to encrypt API Key and API Secret in the console respectively
  • Your_Encrypted_Twitter_Key_2 and Your_Encrypted_Twitter_Secret_2 need to be replaced with the ciphertexts formed after using signature 2 to encrypt API Key and API Secret in the console respectively

3.2 iOS

[warning] Caution Twitter SDK only supports iOS9 and higher versions

1) Configure Twitter App Key and Secret

After adding the iOS plugins of MSDKTwitter, find the MSDKAppSetting.bundle/MSDKConfig.ini file in the Xcode project and add or modify the following settings:

  [Twitter channel configuration]   
    TWITTER_KEY = {Your Twitter key}
    TWITTER_SECRET = {Your Twitter secret}
  • Your Twitter key needs to be replaced with API Key in the management console
  • Your Twitter secret needs to be replaced with API Key in the management console

[warning] Caution Starting from MSDK5.9, the Twitter configuration distinguishes both ends and no longer uses TWITTER_KEY and TWITTER_SECRET. iOS uses TWITTER_KEY_IOS and TWITTER_SECRET_IOS instead. Starting from MSDK5.10.001, no configuration is required here.

2)Xcode project configuration file info.pilst

  <key>CFBundleURLTypes</key>   
  <array>   
    <dict>  
      <key>CFBundleURLSchemes</key> 
      <array>   
        <string>Twitterkit-<API Key></string>   
      </array>  
    </dict> 
  </array>  
  <key>LSApplicationQueriesSchemes</key>    
  <array>   
      <string>Twitter</string>  
      <string>Twitterauth</string>  
  </array>

Where <API Key> needs to be replaced with the game's API Key

3) System library dependencies

  • SafariServices.framework
IV. Function Description

IV. Function Description

4.1 Login Description

  • You can log in the game with the web version of Twitter packaged by MSDK through the following configuration:

    1. In the MSDKConfig.ini file, add the following configuration items:

      [Twitter channel configuration]
         TWITTER_LOGIN_USING_WEB = 1
         TWITTER_WEB_LOGIN_URL = https://cdn.itopsdk.com/v5/{环境}/jssdk/twitterlogin.html
         TWITTER_WEB_LOGIN_URL = https://cdn.itopsdk.com/v5/{Environment}/jssdk/twitterlogin.html
      

      [warning] Caution
      Starting from iOS MSDK5.10.001, only web login is supported, and TWITTER_LOGIN_USING_WEB is not required to be configured.
      Please contact svenzzhou to configure TWITTER_WEB_LOGIN_URL. Example: Singapore environment, the URL is https://cdn.itopsdk.com/v5/sg/jssdk/twitterlogin.html

    2. If the TWITTER_LOGIN_USING_WEB field in the above method is not configured to 1, you can also configure the extension field extraJson as follows to log in the game using the web version when using the login interface Login. But you must configure the TWITTER_WEB_LOGIN_URL field in the MSDKConfig.ini file, otherwise you cannot log in the game normally.

      String extraJson = "{\"loginUsingWeb\":true}";
      MSDKLogin::Login("Twitter", "", "", extraJson);
      
    3. Add an additional callback address in the Twitter console, as shown below.
      Singapore environment:
      https://cdn.itopsdk.com/v5/sg/jssdk/twitterloginSuccess.html
      Silicon Valley environment:
      https://cdn.itopsdk.com/v5/us/jssdk/twitterloginSuccess.html
      The test environment:
      https://cdn.itopsdk.com/v5/test/jssdk/twitterloginSuccess.html
      For other environments, please contact the MSDK backend development for consultation.

    Callback address

  • If you log in the game by using Twitter's official SDK instead of using the web page packaged by MSDK, the above configuration is not required

1.Twitter's official SDK login supports both Twitter App and Web, so it is not required to install Twitter App

2.There will be a cache inside the component after Twitter login is successful, but the processing logics of Android and iOS are different: Android: If Twitter has a login status and Token has not expired, the interface's callback will directly return and refresh the local MSDK login status; (so the Twitter UI can be launched for one time less)
iOS: If Twitter has a login status, iOS will log out of Twitter login status and then continue to perform Twitter login; (Twitter iOS does not support querying whether the token has expired)

3.Note: IOS Web login mode: click "Done" without callback For login failure, there are no error codes to distinguish its causes

4.2 Logout description

  1. Android logout

Starting from MSDK 5.13 version, you can use the following file to configure the domain name cache cleared when Twitter Android logs out:
File path: 'res/values/arrays.xml' under Twitter plugin

<string-array name="twitter_domain_for_clear_cookies">
    <item>https://.twitter.com</item>
    <item>https://.api.twitter.com</item>
</string-array>

The above is the current default value. Under normal circumstances, there is no need to modify it

4.3 Instructions on Twitter Share of the Friend Module

Twitter Share supports text-image-link. As long as one data is filled in, sharing can be performed;

1) Android

  • If Twitter App is not installed, the game's Twitter channel sharing will skip to Twitter webpage sharing; if Twitter App is installed, it will skip to in-app sharing, but image sharing can't be performed until App is installed;
  • Android sharing does not wait for the return of Twitter result but prompts "Success" (sent successfully) in a unified way. For example, when the return is cancelled during the sharing process, MSDK will still prompt that the sharing is successful;

2) IOS (Since MSDK5.10.001 version, it is no longer supported by MSDK)

  • Texts, images and links are all shared through a dialog box popping up in the app. There is no need to install the app;
  • If the shared content contains special characters (<> \ ^, etc.), Twitter SDK will report an error when it is shared. Please avoid using these characters;
  • It is not allowed to share the same content frequently; otherwise, Twitter SDK will report an error like "Twitter failed to send, Twitter not sent";
V. Frequently Asked Questions

V. Frequently Asked Questions

5.1 Twitter sharing failure. Error code: -1011, NSLocalizedDescription=Request failed: unauthorized (401)

After Twitter console modifies permissions, Readpermission cannot be shared. In this case, the logged-in user will fail to share messages. The user needs to launch Twitter login again before sharing messages normally.

permission permission permission



Copyright © 2024 MSDK.
All rights reserved.

results matching ""

    No results matching ""