{"id":19805626,"url":"https://github.com/remirobert/wechatexample","last_synced_at":"2025-02-28T12:19:20.059Z","repository":{"id":72989079,"uuid":"70585770","full_name":"remirobert/WechatExample","owner":"remirobert","description":"Wechat SDK ","archived":false,"fork":false,"pushed_at":"2016-11-07T10:02:16.000Z","size":1405,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-11T06:13:16.659Z","etag":null,"topics":["authentification","wechat","wechat-oauth","wechat-sdk"],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/remirobert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-11T11:18:10.000Z","updated_at":"2018-08-27T08:13:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"6e2980f1-0d1e-4918-9d88-956c00479bf2","html_url":"https://github.com/remirobert/WechatExample","commit_stats":{"total_commits":11,"total_committers":2,"mean_commits":5.5,"dds":0.2727272727272727,"last_synced_commit":"6fff1783d8d3340ab394144f5b697e47b9a668e6"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remirobert%2FWechatExample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remirobert%2FWechatExample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remirobert%2FWechatExample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remirobert%2FWechatExample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remirobert","download_url":"https://codeload.github.com/remirobert/WechatExample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241150244,"owners_count":19918334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentification","wechat","wechat-oauth","wechat-sdk"],"created_at":"2024-11-12T09:04:43.216Z","updated_at":"2025-02-28T12:19:20.054Z","avatar_url":"https://github.com/remirobert.png","language":"Objective-C","readme":"# WechatExample\nWechat SDK example for login and sharing content. 🔫\n\n# installation\n\n - Simply copy the files : **AuthWechatManager.m**, **AuthWechatManager.h**, **WechatUser.m** and **WechatUser.h** into your project.\n - Add also the **wechat SDK** : **libWeChatSDK.a**, **WXApi.h**, **WXApiObject.h** (*chinese version*).\n \n# configuration\n\nFirst you need to add a URL Schemes to your project.\nGo to your **project configuration** \u003e **Info** \u003e **URL Types**\n\nThen add a new one, the **identifier** can be : \"weixin\", the **URL schemes** must be your wechat appId.\n\nTo use your own **wechat credential** (*appID and appSecret*) information, you need to change the top of the file **AuthWechatManager.m**, with your informations : \n\n```Objective-c\n#import \"AuthWechatManager.h\"\n#import \"WXApi.h\"\n#import \"WXApiObject.h\"\n\nNSString *const WECHAT_APP_ID = @\"wx778e68d591bbe9c8\";\nNSString *const WECHAT_APP_SECRET = @\"72b7bdae9cfbfdf768360c628da89c25\";\n```\n\nThen replace by your *appId* and *appSecret*.\n\n# Usage Authentification\n\nTo use the **wechat authentification**, and allow users to log in your app, you need to update your **AppDelegate.m**.\n\nThis is how you need to setup the wechat SDK and init the manager:\n```Objective-c\n- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\n    //init the manager.\n    [[AuthWechatManager shareInstance] initManager];\n    return YES;\n}\n\n- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {\n    if ([[AuthWechatManager shareInstance] isWechatUrl:[url absoluteString]]) {\n        //call your code for handle the wechat action\n        [self handleWechatUrl:url];\n    }\n    return true;\n}\n\n- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {\n    if ([[AuthWechatManager shareInstance] isWechatUrl:[url absoluteString]]) {\n        //call your code for handle the wechat action\n        [self handleWechatUrl:url];\n    }\n    return true;\n}\n```\n\nHow to handle the authentification, the simpliest way to do that, is to add a method in your **AppDelegate.m** file:\n```Objective-c\n- (BOOL)handleWechatUrl:(NSURL *)url {\n    //check if there is a connected user to avoid to handle the Wechat url\n    //If connected return;\n    \n    //present a loading controller, waiting to fetch the user data.\n    return [[AuthWechatManager shareInstance] handleOpenUrl:url completion:^(WechatUser * _Nullable user, NSError * _Nullable error) {\n        //get the user information see the WechatUser model.\n        //preparing to present the profile controller\n        //store the connected user, to keep him logged\n        [[AuthWechatManager shareInstance] initManager];\n        //Your user is logged here.\n        //change the root controller\n    }];\n}\n```\n\n# Usage sharing content\n\nTo share content on Wechat, first the user **need the app**, or all the call will fail.\nThe user doesn't need to be logged to use the wechat sharing feature.\n\nYou can share :\n\n - A link\n - An image\n - A text\n\n```Objective-c\n/*!\n @brief Share a link.\n \n @discussion Share a link, to the Wechat application.\n @param  title a title.\n @param  description a description.\n @param  thumbImage a preview visible on the chat.\n @param  url the link url.\n @param  scene specifie where to send the content : WXSceneTimeline (moment), WXSceneSession (contacts).\n \n @return BOOL return the success status.\n */\n- (BOOL)shareLinkWithTitle:(NSString * _Nullable)title\n               description:(NSString * _Nullable)description\n                thumbImage:(UIImage * _Nullable)thumbImage\n                       url:(NSString * _Nonnull)url\n                        to:(int)scene;\n\n/*!\n @brief Share an image.\n \n @discussion Share an image, to the Wechat application.\n @param  image a image.\n @param  scene specifie where to send the content : WXSceneTimeline (moment), WXSceneSession (contacts).\n \n @return BOOL return the success status.\n */\n- (BOOL)shareImageWithImage:(UIImage * _Nonnull)image to:(int)scene;\n\n/*!\n @brief Share a text.\n \n @discussion Share a text, to the Wechat application.\n @param  text a text.\n @param  scene specifie where to send the content : WXSceneTimeline (moment), WXSceneSession (contacts).\n \n @return BOOL return the success status.\n */\n- (BOOL)shareTextWithText:(NSString * _Nonnull)text to:(int)scene;\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremirobert%2Fwechatexample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremirobert%2Fwechatexample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremirobert%2Fwechatexample/lists"}