docs.unity.cn
Search Results for

    Show / Hide Table of Contents

    Class AuthorizationRequest

    Use this to request authorization to interact with the user when you with to deliver local and remote notifications are delivered to the user's device.

    Inheritance
    object
    AuthorizationRequest
    Implements
    IDisposable
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Unity.Notifications.iOS
    Assembly: solution.dll
    Syntax
    public class AuthorizationRequest : IDisposable
    Remarks

    This method must be called before you attempt to schedule any local notifications. If "Request Authorization on App Launch" is enabled in "Edit -> Project Settings -> Mobile Notification Settings" this method will be called automatically when the app launches. You might call this method again to determine the current authorizations status or retrieve the DeviceToken for Push Notifications. However the UI system prompt will not be shown if the user has already granted or denied authorization for this app.

    Examples
    using (var req = new AuthorizationRequest(AuthorizationOption.Alert | AuthorizationOption.Badge, true))
    {
        while (!req.IsFinished)
        {
            yield return null;
        };
    
        string result = "\n RequestAuthorization: \n";
        result += "\n finished: " + req.IsFinished;
        result += "\n granted :  " + req.Granted;
        result += "\n error:  " + req.Error;
        result += "\n deviceToken:  " + req.DeviceToken;
        Debug.Log(res);
    }

    Constructors

    Name Description
    AuthorizationRequest(AuthorizationOption, bool)

    Initiate an authorization request.

    Properties

    Name Description
    DeviceToken

    A globally unique token that identifies this device to Apple Push Notification Network. Send this token to the server that you use to generate remote notifications. Your server must pass this token unmodified back to APNs when sending those remote notifications. This property will be empty if you set the registerForRemoteNotifications parameter to false when creating the Authorization request or if the app fails registration with the APN.

    Error

    Contains error information of the request failed for some reason or an empty string if no error occurred.

    Granted

    A property indicating whether authorization was granted. The value of this parameter is set to true when authorization was granted for one or more options. The value is set to false when authorization is denied for all options.

    IsFinished

    Indicates whether the authorization request has completed.

    RegisteredForRemoteNotifications

    Whether the app is currently registered for remote notifications.

    Methods

    Name Description
    Dispose()

    Dispose to unregister the OnAuthorizationRequestCompleted callback.

    UnregisterForRemoteNotifications()

    Unregister for remote notifications. This is rarely needed, typically when user logs out. The app can always re-register.

    In This Article
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023