Current location - Quotes Website - Personality signature - How to share the app to WeChat?
How to share the app to WeChat?
1

Application for AppKey

Application method: Visit the background of Youtui website, log in and enter the Application list, and add an app that needs to integrate Youtui components, as shown in the following figure. After successful addition, you can get the AppKey of the application.

2

Before applying for the integration of social platform appkey

, you need to apply for an account for your application on the open platforms of major social networking sites and pass the examination, otherwise you can only call the sharing menu of the system. Unable to track shared callback events and statistical platform

3

Reference youtui library project

Put youtui-lib project library and application project in the same directory

Right-click the root directory of the project in Package Explorer, select Properties, and then click, Click Add in the Android option to add youtui-lib

4

to register the platform to be shared

1. Configure the key of each sharing platform. The configuration file is youtui_sdk.xml, and put it into the assets folder of the project after configuration.

2. If you need to share to which platform, set the Enable attribute of the platform to true.

3. If you need to arrange a platform in front, just change its position in the youtui_sdk.xml file.

5

Matters needing attention for each platform:

Sina Weibo:

Sina Weibo needs to verify the application signature, please be sure to apply the information in the Sina Open Platform Management Center -> Basic information -> Android signature package name information configuration this information

Every time the package name changes or the. keystore used changes, the application signature will change. Please go to Sina Weibo open platform to set it again.

if you recompile when running Demo, because the change of the used. keystore file will also lead to the change of the application signature, which will cause the Demo Sina Weibo share to fail to work normally. Please use the debug.keystore provided in the Demo project package to replace C:\Users\ Debug.keystore file in Administrator.android

WeChat and friends circle:

WeChat and friends circle also need to verify the application signature, please modify the application in WeChat open platform management center -> Develop information configuration.

QQ and QQ space:

QQ and QQ space use tencent's open platform api. Please apply for an account and register an application on Tencent's open platform. Please don't use the configuration of QQ Internet (used for website account login). Although both of them are Tencent's, the two platforms are not universal. In addition to configuring information in youtui_sdk.xml, they also need to be after Tencent in android:scheme in manifest file.

< ? xml version="1." encoding="utf-8"? >

configuration description in the last line: select the function of calling the system sharing menu

6

registering authority in AndroidManifest.xml

7

registering required activity in AndroidManifest.xml

8

WeChat and circle of friends callback settings

If you need to share WeChat and circle of friends, It is necessary to build a package with application package name+.wxapi, and build WXEntryActivity.java under this package. Inherit this class from cn.bidararound.youtui.wxapi.wxentryactivity (there is no need to write code in it)

public class wxentryactivity extensions cn.bidararound.youtui.wxapi.wxentryactivity {}

9

Initialize Youtui

Developers should initialize Youtui sdk at the beginning of their own programs, preferably by calling YtTemplate.init(this) in the onCreate method of MainActivity, so that Youtui sdk can be called later (otherwise, there will be null pointer exceptions in operations such as sharing). For example:

protected void once created (bundle saved state) {super. once created (saved state); setContentView(R.layout.activity_main); YtTemplate.init(this); /Initialize Youtui/initView (); } When the application exits:

Insert the following code YtTemplate.release(this) in the first line of the onDestroy method of the export Activity of your project; This method is used to release memory and count user usage. Once release is called, you must call init again to use the function of friend push, otherwise there will be a null pointer exception.

1

create a ShareData instance and call the set method of this instance to set the data to be shared: create a ShareData instance and call the set method of this instance to set the data that you need to share. See the following for details about this instance. If you just share an application, you only need to set setIsAppShare(true) to share the information and download links filled in by the application in the background of Youtui.

fields contained in the p>ShareData:

isappshare text image path imageurl description title target _ URL to determine whether the text to be shared is a sharing application. The short message should be less than 7 characters, and the Weibo should be less than 14 characters. If a link needs to be shared, It is best to put the link url at the last address of the local picture to be shared. If you share the picture, you need to choose between the local picture and the network picture url. If you share the picture, you need to choose between the local picture and the network picture. If you have both, you need to share the local picture first. The title of the content to be shared and the jumping link of the content to be shared

11

By creating such examples, Call the set method of the instance to set these parameters, for example:

sharedatasharedata = newsharedata (); shareData.isAppShare = false; //If set to true, the shared information is read from the application information filled in by Youtui background, which can be dynamically updated, and the following values need not be set. ShareData.setDescription ("Friends Push Integral Component"); ShareData.setTitle ("sharing by friends"); ShareData.setText ("With a few lines of code, developers can add the function of sharing and sending points for applications, and provide detailed background statistics. In addition to their own sharing function, developers can also integrate the integration function separately on the existing sharing component app,");

shareData.setTarget_url("");

shareData.setImageUrl("");

shareData.setImagePath("");

12

Restrictions and precautions for sharing data on various platforms:

Because of the sharing restrictions on various platforms, please share pictures+links as much as possible when sharing, and rely on links to learn more information

1) WeChat sharing in WeChat friends circle is in the form of linkcard, and the excess text will not be displayed

2) Sina Weibo's very low version of Sina Weibo does not support sending multiple types of Weibo, and only pictures will be shared when sharing pictures and texts. The longest message shared by Sina Weibo is 14 words

3) The longest message shared by QQ and QQ space is 4 words, the longest title shared by QQ is 3 words, the redundant part will be ignored, the description will be ignored, the longest message shared by QQ space is 2 words, the longest title shared by QQ space is 6 words, and the redundant part will be ignored. Description will be ignored

4) Only image(imagePath or imageUrl) and text are shared in Tencent Weibo, and other fields are ignored. The longest message shared by Tencent Weibo is 14 words

5) Only image(imagePath or imageUrl) and text are shared in Renren. Ignore other fields

6) Only text of SMS is shared, and other fields are ignored

7) Only text of email is shared, and other fields are ignored

13

Call youtui sharing recommendation component

Add a sharing recommendation button for the application, such as

14

Call Youtui component in the sharing button event. Example code:

public void once click (view v) {if (v.getid () = = r.id.popup _ bt)

{/Call Youtuiewewtype to share the recommendation component. The constant of YouTuiViewType class is the sharing style parameter. Currently, it supports white list and black grid.//Create a shared template. The first parameter is activity. The second parameter is the sharing window style, and the third parameter is whether integral is required/

yttemplate black temp = new yttemplate (this, youtuiviewtype. black _ popup, false); //The black grid style does not need integral activity/YTTemplate BlackTemp = New YTTemplate (this, youtuiviewtype. white _ list, ture); ///The white list style requires an integral activity

15

Sharedata Sharedata = new Sharedata ();

shareData.isAppShare = false; //If set to true, the shared information is read from the application information filled in by Youtui background, and the later values can be dynamically updated without setting.

shareData.setDescription ("Youtui Integral Component");

sharedata.settile ("sharing by friends");

shareData.setText ("With a few lines of code, the developer can add the function of sharing and sending points to the application, and provide detailed background statistics. In addition to the sharing function, the developer can also integrate the integration function on the app with existing sharing components, so come and try it");

shareData.setTarget_url("");

shareData.setImageUrl("");

shareData.setImagePath("");

blackTemp.setShareData(shareData); //Set the default shared data; See 4.6

/* * for the setting of shareData. If you want to set different sharing information for a certain platform. Set *///blacktemp.adddata (ytplatform.platform _ QQ, sharedata) separately; //Bring up the sharing window blackTemp.show ();

// If you need to customize the sharing event, you can create a listening event. Then handle ytsharelistener Listener 1 = new ytsharelister () {

@ override

public void on success (error info arg)

{

}

@Override public void onPreShare()

{

}

@Override

public void onError(ErrorInfo arg)

{

}

@Override

public void onCancel() {

}

}; //Add the sharing monitor Blacktemp. AddListener (YT platform. platform _ sinaweibo, Listener 1) to Sina Weibo;

// Add sharing listening to QQ//

Blacktemp. AddListener (ytplatform. platform _ QQ, Listener 2); }