Google.Play.Instant.CookieApi

Provides methods that an instant app can use to store a persistent cookie or that an installed app can use to retrieve the cookie that it persisted as an instant app.

Summary

This is a C# implementation of some of the Java methods available in Google Play Services' PackageManagerCompat class.

Public static functions

GetInstantAppCookie()
string
Gets the instant app cookie for this app as a string.
GetInstantAppCookieBytes()
byte[]
Gets the instant app cookie for this app as bytes.
GetInstantAppCookieMaxSizeBytes()
int
Gets the maximum size in bytes of the cookie data an instant app can store on the device.
SetInstantAppCookie(string cookie)
bool
Sets the instant app cookie as a string for the calling app.
SetInstantAppCookieBytes(byte[] cookie)
bool
Sets the instant app cookie as bytes for the calling app.

Classes

Google.Play.Instant.CookieApi.CookieApiException

An exception thrown by the methods of CookieApi if there is a failure while making a call to GooglePlay Services.

Public static functions

GetInstantAppCookie

string GetInstantAppCookie()

Gets the instant app cookie for this app as a string.

Assumes that the cookie was encoded with UTF-8, for example by SetInstantAppCookie. See GetInstantAppCookieBytes for more details.

Details
Exceptions
CookieApiException
Thrown if there is a failure to obtain the cookie.

GetInstantAppCookieBytes

byte[] GetInstantAppCookieBytes()

Gets the instant app cookie for this app as bytes.

Non instant apps and apps that were instant but were upgraded to normal apps can still access this API. For instant apps this cookie is cached for some time after uninstall while for normal apps the cookie is deleted after the app is uninstalled. The cookie is always present while the app is installed.

Details
Exceptions
CookieApiException
Thrown if there is a failure to obtain the cookie.

GetInstantAppCookieMaxSizeBytes

int GetInstantAppCookieMaxSizeBytes()

Gets the maximum size in bytes of the cookie data an instant app can store on the device.

Details
Exceptions
CookieApiException
Thrown if there is a failure to obtain the size.

SetInstantAppCookie

bool SetInstantAppCookie(
  string cookie
)

Sets the instant app cookie as a string for the calling app.

The cookie string will be encoded with UTF-8 and can be recalled using GetInstantAppCookie. See SetInstantAppCookieBytes for more details. Note: the length of the cookie string may not be directly comparable to the size limit indicated by GetInstantAppCookieMaxSizeBytes.

Details
Parameters
cookie
The cookie string.
Exceptions
CookieApiException
Thrown if there is a failure to set the cookie.
Returns
True if the cookie was set. False if cookie is too large or I/O fails.

SetInstantAppCookieBytes

bool SetInstantAppCookieBytes(
  byte[] cookie
)

Sets the instant app cookie as bytes for the calling app.

Non instant apps and apps that were instant but were upgraded to normal apps can still access this API. For instant apps this cookie is cached for some time after uninstall while for normal apps the cookie is deleted after the app is uninstalled. The cookie is always present while the app is installed. The cookie size is limited by GetInstantAppCookieMaxSizeBytes. If the provided cookie size is over the limit, this method returns false. Passing null or an empty array clears the cookie.

Details
Parameters
cookie
The cookie bytes.
Exceptions
CookieApiException
Thrown if there is a failure to set the cookie.
Returns
True if the cookie was set. False if cookie is too large or I/O fails.