How to logout from WeChat programmatically in iOS?

a 夏天 提交于 2020-01-05 06:44:31

问题


I want to logout programatically from wechat just like we do in Facebook and Twitter. Is it possible?

Righty now I have successfully integrated the wechat into my application using WeChat SDK, but when I am pressing the share button (in my application) to share the image on wechat then I am redirected to the wechat application and then after successful uploading return to my application.

But is it possible to stop being redirected to WeChat application? I just simply want to share image without redirect to WeChat application. And also how to share multiple image in once on WeChat?


回答1:


Try this may be its works for you..

 -(void) weChatDidLogout
        {
            NSLog(@"Logged out of wechat");
            NSHTTPCookie *cookie;
            NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
            for (cookie in [storage cookies])
            {
                NSString* domainName = [cookie domain];
                NSRange domainRange = [domainName rangeOfString:@"wechat"];
                if(domainRange.length > 0)
                {
                    [storage deleteCookie:cookie];
                }
            }
        }



回答2:


It seems WeChat SDK does not provide a way in which could share something without redirect to WeChat.

This is because the share function of WeChat does not store any user credential (like OAuth) in your app locally, so it need to redirect every time to know who want to share.



来源:https://stackoverflow.com/questions/25286387/how-to-logout-from-wechat-programmatically-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!