ขั้นตอนนี้เป็นการโหลดโปรแกรมตัวอย่าง line-sdk-starter-ios มาเพื่อใช้งานนะครับ ขั้นตอนการตั้งค่าใช้งานโปรแกรมมีคร่าวๆดังนี้ครับ
- LINE Business Center registered in
- สร้าง Channel
- Download โปรแกรมตัวอย่าง https://github.com/line/line-sdk-starter-ios
- iOS / Android SDK Download ในส่วนนี้จะมีให้โหลดใน account เรานะครับ
- Implementation
หลังจากโหลดโปรแกรมตัวอย่างมาเสร็จก็ unzip และเราจะใช้งานตัวนี้เป็น project นะครับ
ต่อไปก็ดาวน์โหลด SDK มาแล้ว เราแตกไฟล์จะได้ไฟล์ดังนี้
- LineAdapter.framework
- LineAdapterLogin.framework
- LineAdapterUI.framework
- LineAdapterUI.bundle
ทำการ copy ไปไว้ใน project ของเราและเพิ่ม framework เข้าไปใน project เรานะครับ
ตั้งค่า linker flags ตามในรูปข้างล่างนี้
เพิ่ม url type ตามในรูปข้างล่างนี้ line3rdp.{ตรงนี้ให้ใส่ bundle id ของโปรเจคนะครับ}
แก้ไข channel id เป็นของเราที่ไฟล์ LineAdapter.plist (ไฟล์นี้มาจาก LineSDKStarter)
1 2 3 4 5 6 7 8 |
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>ChannelId</key> <string>??????</string> </dict> </plist> |
จากนั้นเรามาดูในส่วนของไฟล์ info.plist ให้หาและแก้ไขค่า line3rdp.{ตรงนี้ให้ใส่ bundle id ของโปรเจคนะครับ}
1 2 3 4 |
<key>CFBundleURLSchemes</key> <array> <string>line3rdp.com.example</string> </array> |
เพิ่ม line app white list ใน info.plist
1 2 3 4 5 |
<key>LSApplicationQueriesSchemes</key> <array> <string>lineauth</string> <string>line3rdp.com.example</string> </array> |
เพิ่ม domain white list ใน info.plist
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
<key>LSRequiresIPhoneOS</key> <true/> <key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>access.line.me</key> <dict> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict> <key>api.line.me</key> <dict> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict> <key>dl.profile.line-cdn.net</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict> <key>dl.profile.line.naver.jp</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict> <key>lcs.naver.jp</key> <dict> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict> <key>obs.line-apps.com</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict> <key>scdn.line-apps.com</key> <dict> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict> </dict> </dict> <key>UILaunchStoryboardName</key> <string>LaunchScreen</string> <key>UIMainStoryboardFile</key> <string>Main</string> <key>UIRequiredDeviceCapabilities</key> <array> <string>armv7</string> </array> <key>UISupportedInterfaceOrientations</key> <array> <string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> |
ลองรันโปรแกรมตัวอย่างทดสอบดูครับ
0