iOS開発-微信の簡単なテキスト共有(公式SDKを統合)
12899 ワード
前言
開発ツール:XCode 7.3.1 SDKバージョン:V 1.7.1
一.APP提出審査
前期準備:このブログを参考にすることができますhttp://www.jianshu.com/p/839dc30f2250iOSバージョンではBundle Idを提供するだけで済みます
500CD4E3-4EE2-449F-8BF6-32D3102D1605.png
注意:ダウンロードアドレスの適用は必須ではありません
承認後にAppID、AppSecretを取得できます
appid.png
二.環境構築
1.最新のSDKをダウンロード
ダウンロードアドレスhttps://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419319164&token=fdf6c5d38e9c82f85ebf72374441beff257c4849&lang=zh_CN
iOSリソースのダウンロードpng
2.SDKのインポート
SDKをインポートする.png
3.プロジェクト構成
a.HTTPリクエストをサポートする設定
HTTPリクエストをサポートする.png
参考文献:http://www.jianshu.com/p/5935dff47e4f
b.shemeホワイトリストの設定
Schemeホワイトリストを設定します.png
参考文献:http://www.jianshu.com/p/f974f4cbba18
c.bitcodeを閉じる
bitcode 1を無効にする.png
bitcode 2を無効にする.png
d.URLの設定
URLを設定します.png
e.Build phasesの設定
Build phasesを設定します.png
三.コード統合
1.登録ID、コールバック処理
2.共有コアコード
四.よくある質問のまとめ(出会った穴...)
1.公式Demoコンパイルエラー
ダウンロード先:https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419319164&token=fdf6c5d38e9c82f85ebf72374441beff257c4849&lang=zh_CN解決策:
解决策png
公式Demo:(公式のdemoを直接実行すると各種エラーが報告されます...、間違いのないバージョンを提供します)https://github.com/andli0626/wx_demo_for_iOS-V1.7.1.git
五.参考資料
公式ドキュメント
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=1417694084&token=fdf6c5d38e9c82f85ebf72374441beff257c4849&lang=zh_CN
公式API更新説明:
実装効果図
未命名の画像png
ソース:https://github.com/andli0626/wx_sharedemo_for_iOS-V1.7.1.git
何事も最初は難しいので、簡単なテキスト共有を完成し、後の他のAPIの使用は公式ドキュメントを参考にして、一歩一歩実践することができます.
作者:Jin牌码男
リンク:http://www.jianshu.com/p/c9b688fdb961
出典:簡書
著作権は作者の所有である.商業転載は著者に連絡して許可を得てください.非商業転載は出典を明記してください.
開発ツール:XCode 7.3.1 SDKバージョン:V 1.7.1
一.APP提出審査
前期準備:このブログを参考にすることができますhttp://www.jianshu.com/p/839dc30f2250iOSバージョンではBundle Idを提供するだけで済みます
500CD4E3-4EE2-449F-8BF6-32D3102D1605.png
注意:ダウンロードアドレスの適用は必須ではありません
承認後にAppID、AppSecretを取得できます
appid.png
二.環境構築
1.最新のSDKをダウンロード
ダウンロードアドレスhttps://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419319164&token=fdf6c5d38e9c82f85ebf72374441beff257c4849&lang=zh_CN
iOSリソースのダウンロードpng
2.SDKのインポート
SDKをインポートする.png
3.プロジェクト構成
a.HTTPリクエストをサポートする設定
HTTPリクエストをサポートする.png
参考文献:http://www.jianshu.com/p/5935dff47e4f
b.shemeホワイトリストの設定
Schemeホワイトリストを設定します.png
参考文献:http://www.jianshu.com/p/f974f4cbba18
c.bitcodeを閉じる
bitcode 1を無効にする.png
bitcode 2を無効にする.png
d.URLの設定
URLを設定します.png
e.Build phasesの設定
Build phasesを設定します.png
三.コード統合
1.登録ID、コールバック処理
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//
NSString *APPID = @" AppID";
//
[WXApi registerApp:APPID];
return YES;
}
-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
return [WXApi handleOpenURL:url delegate:self];
}
-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options{
return [WXApi handleOpenURL:url delegate:self];
}
#pragma mark WXApiDelegate
// onReq , 。 sendRsp 。 sendRsp ,
- (void)onReq:(BaseReq *)req
{
NSLog(@"onReq , 。 sendRsp 。 sendRsp , ");
}
// sendReq , onResp 。sendReq ,
- (void)onResp:(BaseResp *)resp
{
NSLog(@" ");
//
if ([resp isKindOfClass:[SendMessageToWXResp class]]) {
switch (resp.errCode) {
case WXSuccess:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@" "
message:@" !"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alert show];
}
break;
default:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@" "
message:@" !"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alert show];
}
break;
}
}
}
2.共有コアコード
//
-(IBAction)clickShareButton:(id)sender{
SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
req.text = @" ";
req.bText = YES;
//
// WXSceneSession
// WXSceneTimeline
// WXSceneFavorite
req.scene = WXSceneSession;
[WXApi sendReq:req];
}
四.よくある質問のまとめ(出会った穴...)
1.公式Demoコンパイルエラー
ダウンロード先:https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419319164&token=fdf6c5d38e9c82f85ebf72374441beff257c4849&lang=zh_CN解決策:
解决策png
公式Demo:(公式のdemoを直接実行すると各種エラーが報告されます...、間違いのないバージョンを提供します)https://github.com/andli0626/wx_demo_for_iOS-V1.7.1.git
五.参考資料
公式ドキュメント
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=1417694084&token=fdf6c5d38e9c82f85ebf72374441beff257c4849&lang=zh_CN
公式API更新説明:
# SDK1.7.1
1. ipv6( )
2. xCode Version 7.3.1 (7D1014)
# SDK1.7
1. ipv6
2.
# SDK1.6.3
1.xCode7.2 sdk 。
2. xCode7.2 。
3. Build
Phases Link Security.framework
4. 。
# SDK1.6.2
1、xCode7.1 sdk
2、 xCode7.1
# SDK1.6.1
1、 armv7s ,bitcode
2、 warning
# SDK1.6
1、iOS 9 , http , “Info.plist” URL
Schemes , 。
, iOS9 SDK ( 、 、 、 ) , “Info.plist” :
LSApplicationQueriesSchemes
weixin
NSAppTransportSecurity
NSAllowsArbitraryLoads
2、 CoreTelephony.framework
3、 bitcode
# SDK1.5
1、 safeSendReq: , sendReq: 。
2、 +(BOOL)
sendAuthReq:(SendAuthReq*) req viewController : (UIViewController*)
viewController delegate:(id ) delegate;
Auth, WXApi.h
3、 , 。 :SystemConfiguration.framework,libz.dylib,libsqlite3.0.dylib。
実装効果図
未命名の画像png
ソース:https://github.com/andli0626/wx_sharedemo_for_iOS-V1.7.1.git
何事も最初は難しいので、簡単なテキスト共有を完成し、後の他のAPIの使用は公式ドキュメントを参考にして、一歩一歩実践することができます.
作者:Jin牌码男
リンク:http://www.jianshu.com/p/c9b688fdb961
出典:簡書
著作権は作者の所有である.商業転載は著者に連絡して許可を得てください.非商業転載は出典を明記してください.