Intégration expérimentale réservée à iOS 15 ou ultérieur avec Swift Package Manager. Android et le Web ne sont pas pris en charge.
method initialize(...)
initialize(options: InitializeOptions) => Promise<void>
Enregistrez l’écouteur customerSessionRequested avant l’initialisation. Appelez reset avant de changer d’utilisateur.
method setCustomerSession(...)
setCustomerSession(options: CustomerSessionResponse) => Promise<void>
Répondez une seule fois à chaque demande de session, dans un délai de 30 secondes. Les réponses périmées ou en double sont rejetées.
getBuyButton(options: { id: string; }) => Promise<BuyButton>
| Paramètre |
Type |
options |
{ id: string; } |
Renvoie : Promise<BuyButton>
presentBuyButton(options: { id: string; }) => Promise<void>
Affiche le bouton d’achat natif du SDK. La promesse se résout dès son affichage, avant toute confirmation de paiement.
| Paramètre |
Type |
options |
{ id: string; } |
method getActiveEntitlements(...)
getActiveEntitlements(options?: { forceRefresh?: boolean | undefined; } | undefined) => Promise<{ entitlements: Entitlement[]; }>
| Paramètre |
Type |
options |
{ forceRefresh?: boolean; } |
Renvoie : Promise<{ entitlements: Entitlement[]; }>
method hasEntitlement(...)
hasEntitlement(options: { lookupKey: string; forceRefresh?: boolean; }) => Promise<{ active: boolean; }>
| Paramètre |
Type |
options |
{ lookupKey: string; forceRefresh?: boolean; } |
Renvoie : Promise<{ active: boolean; }>
method presentCustomerPortal(...)
presentCustomerPortal(options?: { external?: boolean | undefined; } | undefined) => Promise<void>
Ouvre par défaut le portail dans l’application. La promesse se résout dès l’affichage du portail ou l’ouverture du navigateur, indépendamment de toute modification de l’abonnement.
| Paramètre |
Type |
options |
{ external?: boolean; } |
method reset()
Annule les opérations en cours, ferme l’interface du plugin et efface la session et les caches. Rappelez initialize avant de réutiliser le plugin.
method addListener('customerSessionRequested', ...)
addListener(eventName: 'customerSessionRequested', listenerFunc: (event: { requestId: string; }) => void) => Promise<PluginListenerHandle>
Demandez une nouvelle Customer Session à votre serveur pour chaque requête. Ne mettez jamais son secret en cache.
| Paramètre |
Type |
eventName |
'customerSessionRequested' |
listenerFunc |
(event: { requestId: string; }) => void |
Renvoie : Promise<PluginListenerHandle>
method addListener('entitlementsChanged', ...)
addListener(eventName: 'entitlementsChanged', listenerFunc: (event: { entitlements: Entitlement[]; }) => void) => Promise<PluginListenerHandle>
Signale que le SDK a actualisé les droits d’accès. Cet événement ne constitue pas un abonnement aux notifications du serveur.
| Paramètre |
Type |
eventName |
'entitlementsChanged' |
listenerFunc |
(event: { entitlements: Entitlement[]; }) => void |
Renvoie : Promise<PluginListenerHandle>
method addListener('billingError', ...)
addListener(eventName: 'billingError', listenerFunc: (event: { message: string; }) => void) => Promise<PluginListenerHandle>
Signale une erreur survenue lorsque l’utilisateur appuie sur le bouton d’achat natif affiché.
| Paramètre |
Type |
eventName |
'billingError' |
listenerFunc |
(event: { message: string; }) => void |
Renvoie : Promise<PluginListenerHandle>
method removeAllListeners()
removeAllListeners() => Promise<void>