Technical Q&A QA1932

Supporting In-App Purchase in iMessage apps.

Q:  My iMessage app uses the compact presentation style and supports in-app purchase. The keyboard comes up when signing in to authenticate my purchase. However, my app loses state once the keyboard is dismissed. How do I resolve this issue?

A: There is an issue that will cause an iMessage app supporting in-app purchase to lose state when dismissing the keyboard in compact style.

To workaround this issue, only perform in-app purchase in expanded style. If in-app purchase was started in compact style, request to transition your extension's user interface to the expanded style by setting requestPresentationStyle to .expanded before proceeding as shown in Listing 1.

Listing 1   Request to transition to the expanded mode (Swift).

requestPresentationStyle(.expanded)

Listing 2  Request to transition to the expanded mode (Objective-C).

[self requestPresentationStyle:MSMessagesAppPresentationStyleExpanded];

As an example, see the #images app displayed in Messages app drawer, which contains a search field as shown in Figure 1. When the search field is tapped, the user interface is transitioned to the expanded style before enabling input as shown in Figure 2.

Figure 1  The #images app in Messages app drawer.
Figure 2  The #images app in expanded presentation style after tapping in its search field.


Document Revision History


DateNotes
2016-08-23

New document that describes how to support in-app purchase in iMessage apps.