[iOS 10] 메시지 확장'iMessage Application'으로 메시지 애플리케이션을 만들어 봤습니다♪
개시하다
안녕하세요!예(/)
9월 발표된 iOS 10에서는 확장기능(Extension) 메시지 애플리케이션이 등장했으나 아직 사용되지 않아 간단한 앱을 만들었다.
이 확장 기능은'Sticker Pack Application'과'iMessage Application'두 가지로 나뉘는데 이번에는'iMessage Application'을 사용했다.p>
프로젝트 작성
우선 위쪽 메뉴부터 File->New -> Project로 이동하여 다음 iOS 태그의 iMessage에서 메시지 확장 프로젝트를 작성합니다.p>
스토리보드는 아래 그림과 같이 시작할 때의 컨트롤러는 MS Messagees AppViewController를 계승한 Message ViewController입니다p>
MessagesViewController
다음으로, MS Message AppViewController에서 아래 그림과 같이 호출하는 방법이 있습니다. 이 호출 방법을 실시하여 메시지 확장을 만듭니다.p>
import UIKit
import Messages
class MessagesViewController: MSMessagesAppViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Conversation Handling
override func willBecomeActive(with conversation: MSConversation) {
// Called when the extension is about to move from the inactive to active state.
// This will happen when the extension is about to present UI.
// Use this method to configure the extension and restore previously stored state.
}
override func didResignActive(with conversation: MSConversation) {
// Called when the extension is about to move from the active to inactive state.
// This will happen when the user dissmises the extension, changes to a different
// conversation or quits Messages.
// Use this method to release shared resources, save user data, invalidate timers,
// and store enough state information to restore your extension to its current state
// in case it is terminated later.
}
override func didReceive(_ message: MSMessage, conversation: MSConversation) {
// Called when a message arrives that was generated by another instance of this
// extension on a remote device.
// Use this method to trigger UI updates in response to the message.
}
override func didStartSending(_ message: MSMessage, conversation: MSConversation) {
// Called when the user taps the send button.
}
override func didCancelSending(_ message: MSMessage, conversation: MSConversation) {
// Called when the user deletes the message without sending it.
// Use this to clean up state related to the deleted message.
}
override func willTransition(to presentationStyle: MSMessagesAppPresentationStyle) {
// Called before the extension transitions to a new presentation style.
// Use this method to prepare for the change in presentation style.
}
override func didTransition(to presentationStyle: MSMessagesAppPresentationStyle) {
// Called after the extension transitions to a new presentation style.
// Use this method to finalize any behaviors associated with the change in presentation style.
}
}
MSConversation
MSConversation 클래스는 메시지 응용 프로그램에서 대화하는 클래스를 나타냅니다.이 분류를 사용하면 현재 선택한 메시지나 대화의 다양한 대상에 접근할 수 있습니다br/>
참조: API Reference MSConversation
사용한 이미지는 Assets입니다.xcassets에 추가(icon도 설정)합니다.
스토리보드에 기본적으로 설치된 Hello World 탭을 삭제하고 UIButton 대신 imge를 설정하고 Buton의 동작을 기술합니다p>
MSConversation 클래스의 insert (MSmessage) 를 사용하여 이미지와 메시지를 포함하는 내용을 발송 대상으로 합니다.MSMessage 레이아웃은 MSMessage TemplateLayout을 사용합니다.p>
@IBAction func send(_ sender: AnyObject) {
let message = MSMessage()
let template = MSMessageTemplateLayout()
template.image = UIImage(named: "2")
template.caption = "Hello! I'm rabbit!"
template.subcaption = "How are you?"
message.layout = template
self.activeConversation?.insert(message, completionHandler: { (error) in
print("insearted! error:\(error)")
})
dismiss()
}
실행 결과
위 작업을 수행한 후 아래와 같이
최후
정보 기능을 간단하게 사용할 수 있고 편리한 기능을 가진 응용 소프트웨어가 끊임없이 등장하여 향후의 발전을 기대한다(\/
)참조 링크
iMessage + Apps
API Reference Messages Framework
iMessage Apps and Stickers, Part 1
iMessage Apps and Stickers, Part 2
SampleCode Ice Cream Builder: A simple Messages app extension
Related articles across the web
-
Inline game videos? Cool apps that demo the power of iMessage integration in iOS 10 -
iOS 10 improves conversational capabilities -
iOS 10 Messages: Best Stickers, Games, Apps For iMessage -
Apple Releases Xcode 8 With Swift 3 and SDKs for iOS 10, watchOS 3, tvOS 10, and macOS Sierra -
Get iOS 10 today! Here's everything you need to know about Apple's latest software update
Reference
이 문제에 관하여([iOS 10] 메시지 확장'iMessage Application'으로 메시지 애플리케이션을 만들어 봤습니다♪), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/aska52/items/f9f2ff8e576d337a2aae텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)