Share via


WalletItemStore.AddAsync(String, WalletItem) Method

Definition

Caution

The ApplicationModel.Wallet namespace is no longer supported, and will soon be deprecated. Developers are encouraged to avoid using this namespace.

Adds a new wallet item to the wallet.

public:
 virtual IAsyncAction ^ AddAsync(Platform::String ^ id, WalletItem ^ item) = AddAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncAction AddAsync(winrt::hstring const& id, WalletItem const& item);
/// [Windows.Foundation.Metadata.RemoteAsync]
/// [Windows.Foundation.Metadata.Deprecated("IWalletItemStore is deprecated and might not work on all platforms. For more info, see MSDN.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 917504, "Windows.Foundation.UniversalApiContract")]
IAsyncAction AddAsync(winrt::hstring const& id, WalletItem const& item);
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncAction AddAsync(string id, WalletItem item);
[Windows.Foundation.Metadata.RemoteAsync]
[Windows.Foundation.Metadata.Deprecated("IWalletItemStore is deprecated and might not work on all platforms. For more info, see MSDN.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 917504, "Windows.Foundation.UniversalApiContract")]
public IAsyncAction AddAsync(string id, WalletItem item);
function addAsync(id, item)
Public Function AddAsync (id As String, item As WalletItem) As IAsyncAction

Parameters

id
String

Platform::String

winrt::hstring

The identifier of the wallet item. This value must be unique. This sets the initial WalletItem.Id value (the identifier is for the WalletItemStore store, and isn't part of the initialization of a WalletItem object.

item
WalletItem

The wallet item to add to the wallet.

Returns

An asynchronous action. If you use Asynchronous programming, the return type is void.

Attributes

Remarks

If the id value passed in to this method is not unique, or if the item has already been added to the wallet, an exception is thrown. How to handle errors/exceptions varies by programming language, particularly so when calling asynchronous methods. See Asynchronous programming.

Remember that when you call this method, the item is added to the wallet item store, which is owned by the device not the app. While you're still developing, the store persists across app sessions, and so attempting to add the same item again when running another debug session can throw an exception because the item's already there. Consider adding a call to ClearAsync before you attempt to add any items and you've run your code more than once, at least while you're still developing and testing your code.

Applies to

See also