示例#1
0
    /// <summary>
    /// Called when Unity IAP is ready to make purchases.
    /// </summary>
    public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    {
        this.controller = controller;
        this.extensions = extensions;

        OnInitiated?.Invoke();
    }
        internal void MessageStateChangeHandler(MessagingEventParams eventParams, MessagingEventParams.StateParams stateParams)
        {
            Message message = new Message()
            {
                Body      = stateParams.Body,
                Context   = stateParams.Context,
                Direction = stateParams.Direction,
                From      = stateParams.FromNumber,
                ID        = stateParams.MessageID,
                Media     = stateParams.Media,
                Reason    = stateParams.Reason,
                Segments  = stateParams.Segments,
                State     = stateParams.MessageState,
                Tags      = stateParams.Tags,
                To        = stateParams.ToNumber,
            };

            OnMessageStateChange?.Invoke(this, message, eventParams, stateParams);

            switch (stateParams.MessageState)
            {
            case MessageState.queued:
                OnMessageQueued?.Invoke(this, message, eventParams, stateParams);
                break;

            case MessageState.initiated:
                OnInitiated?.Invoke(this, message, eventParams, stateParams);
                break;

            case MessageState.sent:
                OnMessageSent?.Invoke(this, message, eventParams, stateParams);
                break;

            case MessageState.delivered:
                OnMessageDelivered?.Invoke(this, message, eventParams, stateParams);
                break;

            case MessageState.undelivered:
                OnMessageUndelivered?.Invoke(this, message, eventParams, stateParams);
                break;

            case MessageState.failed:
                OnMessageFailed?.Invoke(this, message, eventParams, stateParams);
                break;
            }
        }