React-native-onesignal: Dactylographies

Créé le 3 avr. 2018  ·  23Commentaires  ·  Source: OneSignal/react-native-onesignal

Salut les gars, travail génial, pouvez-vous s'il vous plaît ajouter le support dactylographié ?

Je travaille sur un projet en utilisant dactylographié, mais vous n'avez pas de support pour cela :(

Enhancement / Feature

Commentaire le plus utile

Bonjour @DavidNorena

Vous pouvez ajouter ces saisies à votre projet manuellement :

declare module 'react-native-onesignal' {

    enum InFocusDisplayOption {
        none = 0,
        inAppAlert = 1,
        notification = 2
    }

    enum LogLevel {
        None = 0,
        Fatal = 1,
        Errors = 2,
        Warnings = 3,
        Info = 4,
        Debug = 5,
        Verbose = 6
    }

    type oneSignalEvents = 'received' | 'opened' | 'ids';

    interface Settings {
        kOSSettingsKeyAutoPrompt: boolean,
        kOSSettingsKeyInAppLaunchURL: boolean,
        kOSSSettingsKeyPromptBeforeOpeningPushURL: boolean,
        kOSSettingsKeyInFocusDisplayOption: InFocusDisplayOption
    }

    interface PushData {
        notificationID: string,
        contentAvailable: boolean,
        badge?: number,
        sound: string,
        title: string,
        body: string,
        launchURL?: string,
        additionalData?: object,
        p2p_notification?: Array<any>
    }

    interface OpenResult {
        notification: {
            payload: PushData,
            isAppInFocus: boolean
        }
    }

    interface Permissions {
        alert: boolean,
        badge: boolean,
        sound: boolean
    }

    /**
     * shown If the notification was displayed to the user or not
     * payload the push data
     * displayType The display method of a received notification
     * silentNotification Wether the received notification was a silent one
     */
    interface ReceivedNotification {
        shown: boolean,
        payload: PushData,
        displayType: InFocusDisplayOption,
        silentNotification: boolean
    }


    export default class OneSignal {
        /**
         * Initialize Onesignal
         * <strong i="8">@param</strong> {string} appId Your app id you can get from OneSignal control panel.
         * <strong i="9">@param</strong> {"react-native-onesignal".Settings} settings (Optional) Settings for ios.
         */
        public static init(appId: string, settings?: Settings): void;

        /**
         * Undocumented function.
         */
        public static Configure( undocumentedParam1?: any, undocumentedParam2?: any) : void;

        /**
         * You can set tag for user with this function.
         * <strong i="10">@param</strong> {string} key Tag name you want to add to user.
         * <strong i="11">@param</strong> {string} value Tag value
         */
        public static sendTag(key: string, value: string): void;

        /**
         * You can set multiple tags for user with this function.
         * <strong i="12">@param</strong> {object} tags Tags you want to set. Sample: {key1: 'value1', key2: 'value2'}
         */
        public static sendTags(tags: object): void;

        /**
         * Getting the tags from the server and use the received object
         * <strong i="13">@param</strong> {Function} handler You can read tags from this parameter.
         */
        public static getTags(handler: (receivedTags: any) => {}): void;

        /**
         * Allows you to check whether notifications are enabled for the app, whether user is subscribed to notifications through OneSignal, and what the user's in-app subscription preference is. It also provides access to pushToken and userId
         * <strong i="14">@param</strong> {Function} handler Handler function you can read subscription status from first parameter.
         */
        public static getPermissionSubscriptionState(handler: (status: any) => {}): void;

        /**
         * You can delete tag from user with this function.
         * <strong i="15">@param</strong> {string} key Tag name you want to delete from user.
         */
        public static deleteTag(key: string): void;

        /**
         * OneSignal now allows you to send emails to your userbase. This email can be set using the OneSignal react-native SDK.
         * <strong i="16">@param</strong> {string} email User's email address.
         * <strong i="17">@param</strong> {string} emailAuthCode Email auth code should be securely generated by your backend server
         * <strong i="18">@param</strong> {Function} callback Handler function for error if it occurred
         */
        public static setEmail(email: string, emailAuthCode: string, callback: (error?: any) => {}): void;

        /**
         * If you don't want to implement email auth hashing on your backend (which is heavily recommended), you can still use the OneSignal email feature in an unauthenticated state with this function.
         * <strong i="19">@param</strong> {string} email User's email address.
         * <strong i="20">@param</strong> {Function} callback Handler function for error if it occurred
         */
        public static setEmail(email: string, callback: (error?: any) => {}): void;

        /**
         * If your application implements logout functionality, you can logout of the OneSignal email for this user using the logout function.
         * <strong i="21">@param</strong> {Function} callback Handler function for error if it occurred
         */
        public static logoutEmail(callback: (error?: any) => {}): void;

        /**
         * You can call this from your UI from a button press for example to give your user's options for your notifications. By default OneSignal always vibrates the device when a notification is displayed unless the device is in a total silent mode. Passing false means that the device will only vibrate lightly when the device is in it's vibrate only mode.
         * <strong i="22">@param</strong> {boolean} setTo New value you want to set.
         */
        public static enableVibrate(setTo: boolean): void;

        /**
         * You can call this from your UI from a button press for example to give your user's options for your notifications. By default OneSignal plays the system's default notification sound when the device's notification system volume is turned on. Passing false means that the device will only vibrate unless the device is set to a total silent mode.
         * <strong i="23">@param</strong> {boolean} setTo New value you want to set.
         */
        public static enableSound(setTo: boolean): void;

        /**
         * You can call this method with false to opt users out of receiving all notifications through OneSignal. You can pass true later to opt users back into notifications
         * <strong i="24">@param</strong> {boolean} setTo New value you want to set.
         */
        public static setSubscription(setTo: boolean): void;

        /**
         * Promts location permission to user.
         */
        public static promptLocation(): void;

        /**
         * Removes all OneSignal notifications from the Notification Shade.
         */
        public static clearOneSignalNotifications(): void;

        /**
         * Disable or enable location collection (defaults to enabled if your app has location permission).
         * <strong i="25">@param</strong> {boolean} setTo New value you want to set.
         */
        public static setLocationShared(setTo: boolean): void;

        /**
         * Prompts the user for location permissions. This allows for geotagging so you can send notifications to users based on location.
         *
         * Note: Make sure you also have the required location permission in your AndroidManifest.xml. For iOS, make sure you set the NSLocationWhenInUseUsageDescription or the NSLocationAlwaysUsageDescription in your info.plist. (Location Always also requires the location background mode capability)
         * <strong i="26">@param</strong> {"react-native-onesignal".InFocusDisplayOption} setTo New value you want to set.
         */
        public static inFocusDisplaying(setTo: InFocusDisplayOption): void;

        /**
         * P2P notification
         * <strong i="27">@param</strong> {object} contents Sample: { en: 'English Message', tr: 'Türkçe Mesaj' }
         * <strong i="28">@param</strong> {Array<any>} data Some array for payload
         * <strong i="29">@param</strong> {string} playerId OneSignal Player Id you want to send message to.
         * <strong i="30">@param</strong> {object} otherParameters Sample: {"ios_attachments" : {"image1" : "{image_url}"}}
         */
        public static postNotification(contents: object, data: Array<any>, playerId: string, otherParameters?: object): void;

        /**
         * Cancels a single OneSignal notification based on its Android notification integer id. You can get the notification Id when invoking OneSignal.onNotificationOpened while receiving a notification.
         * <strong i="31">@param</strong> {string} notificationId Notification id you want to cancel.
         */
        public static cancelNotification( notificationId: string ): void;

        /**
         * See what push permissions are currently enabled. callback will be invoked with a permissions object (currently supported only on iOS).
         * <strong i="32">@param</strong> {Function} callback Callback function you can read the permissions from first parameter.
         */
        public static checkPermissions( callback: (permissions: any) => {}): void;

        /**
         * Requests Push Notification Permissions (iOS Only)
         * <strong i="33">@param</strong> {"react-native-onesignal".Permissions} permissions Permissions you want to ask.
         */
        public static requestPermissions( permissions: Permissions ): void;

        /**
         * Call when you want to prompt the user to accept push notifications. Only call once and only if you passed <strong i="34">@NO</strong> to kOSSettingsKeyAutoPrompt on init.
         */
        public static registerForPushNotifications(): void;

        /**
         * IMPORTANT: Use this function before OneSignal.init
         *
         * Allows you to delay the initialization of the SDK until the user provides privacy consent. The SDK will not be fully initialized until the provideUserConsent(true) method is called.
         *
         * If you set this to be true, the SDK will not fully initialize until consent is provided. You can still call OneSignal methods, but nothing will happen, and the user will not be registered for push notifications.
         * <strong i="35">@param</strong> {boolean} wtf I don't know why this function asking boolean parameter. Just pass true if you don't know what you are doing.
         */
        public static setRequiresUserPrivacyConsent(wtf: boolean): void;

        /**
         * Will initialize the SDK and register for push notifications.
         * <strong i="36">@param</strong> {boolean} wtf I don't know why this function asking boolean parameter. Just pass true if you don't know what you are doing.
         */
        public static provideUserConsent(wtf: boolean): void;

        /**
         * Enable logging to help debug if you run into an issue setting up OneSignal.
         * <strong i="37">@param</strong> {"react-native-onesignal".LogLevel} logLevel Sets the logging level to print to the iOS Xcode log or the Android LogCat log.
         * <strong i="38">@param</strong> {"react-native-onesignal".LogLevel} visualLevel Sets the logging level to show as alert dialogs.
         */
        public static setLogLevel( logLevel: LogLevel, visualLevel: LogLevel ): void;

        /**
         * You can bind events with this function.
         * <strong i="39">@param</strong> {"react-native-onesignal".oneSignalEvents} type Event type you want to subscribe
         * <strong i="40">@param</strong> {Function} handler Handler function
         */
        public static addEventListener(type: oneSignalEvents, handler: Function): void;

        /**
         * You can remove binded events with this function.
         * <strong i="41">@param</strong> {"react-native-onesignal".oneSignalEvents} type Event type you want to subscribe
         * <strong i="42">@param</strong> {Function} handler (Optional) Handler function for solo remove.
         */
        public static removeEventListener(type: oneSignalEvents, handler?: Function): void;
    }
}

Tous les 23 commentaires

moi aussi, ne travaille-t-on pas à un signal dactylographié natif ?

@sionnita , vous pouvez l'utiliser dans des fichiers dactylographiés (.tsx, .ts), en utilisant vainilla javascript, comme expliqué dans la documentation, mais vous perdrez les saisies IDE et le support de la saisie semi-automatique ! et si vous utilisez tslint, vous aurez beaucoup d'erreurs et d'avertissements, c'est pourquoi j'ai demandé le fichier de définitions.

Je ne l'ai pas encore testé, mais il semble que @krystofcelba il y a quelques mois a créé une pull request #395 dans laquelle il a ajouté les typages TypeScript , mais je pense qu'elle n'est pas complète ou est incompatible parce que toute la pull request ne l'a pas fait ' t le rendre à la branche master pour cette raison .

Peut-être que @krystofcelba ou quelqu'un d'autre pourrait nous aider à ne demander que le fichier de définitions dactylographié, je le ferais mais pour le moment, je n'ai pas le temps de le faire :(

Bonne journée les gars !

Bonjour @DavidNorena

Vous pouvez ajouter ces saisies à votre projet manuellement :

declare module 'react-native-onesignal' {

    enum InFocusDisplayOption {
        none = 0,
        inAppAlert = 1,
        notification = 2
    }

    enum LogLevel {
        None = 0,
        Fatal = 1,
        Errors = 2,
        Warnings = 3,
        Info = 4,
        Debug = 5,
        Verbose = 6
    }

    type oneSignalEvents = 'received' | 'opened' | 'ids';

    interface Settings {
        kOSSettingsKeyAutoPrompt: boolean,
        kOSSettingsKeyInAppLaunchURL: boolean,
        kOSSSettingsKeyPromptBeforeOpeningPushURL: boolean,
        kOSSettingsKeyInFocusDisplayOption: InFocusDisplayOption
    }

    interface PushData {
        notificationID: string,
        contentAvailable: boolean,
        badge?: number,
        sound: string,
        title: string,
        body: string,
        launchURL?: string,
        additionalData?: object,
        p2p_notification?: Array<any>
    }

    interface OpenResult {
        notification: {
            payload: PushData,
            isAppInFocus: boolean
        }
    }

    interface Permissions {
        alert: boolean,
        badge: boolean,
        sound: boolean
    }

    /**
     * shown If the notification was displayed to the user or not
     * payload the push data
     * displayType The display method of a received notification
     * silentNotification Wether the received notification was a silent one
     */
    interface ReceivedNotification {
        shown: boolean,
        payload: PushData,
        displayType: InFocusDisplayOption,
        silentNotification: boolean
    }


    export default class OneSignal {
        /**
         * Initialize Onesignal
         * <strong i="8">@param</strong> {string} appId Your app id you can get from OneSignal control panel.
         * <strong i="9">@param</strong> {"react-native-onesignal".Settings} settings (Optional) Settings for ios.
         */
        public static init(appId: string, settings?: Settings): void;

        /**
         * Undocumented function.
         */
        public static Configure( undocumentedParam1?: any, undocumentedParam2?: any) : void;

        /**
         * You can set tag for user with this function.
         * <strong i="10">@param</strong> {string} key Tag name you want to add to user.
         * <strong i="11">@param</strong> {string} value Tag value
         */
        public static sendTag(key: string, value: string): void;

        /**
         * You can set multiple tags for user with this function.
         * <strong i="12">@param</strong> {object} tags Tags you want to set. Sample: {key1: 'value1', key2: 'value2'}
         */
        public static sendTags(tags: object): void;

        /**
         * Getting the tags from the server and use the received object
         * <strong i="13">@param</strong> {Function} handler You can read tags from this parameter.
         */
        public static getTags(handler: (receivedTags: any) => {}): void;

        /**
         * Allows you to check whether notifications are enabled for the app, whether user is subscribed to notifications through OneSignal, and what the user's in-app subscription preference is. It also provides access to pushToken and userId
         * <strong i="14">@param</strong> {Function} handler Handler function you can read subscription status from first parameter.
         */
        public static getPermissionSubscriptionState(handler: (status: any) => {}): void;

        /**
         * You can delete tag from user with this function.
         * <strong i="15">@param</strong> {string} key Tag name you want to delete from user.
         */
        public static deleteTag(key: string): void;

        /**
         * OneSignal now allows you to send emails to your userbase. This email can be set using the OneSignal react-native SDK.
         * <strong i="16">@param</strong> {string} email User's email address.
         * <strong i="17">@param</strong> {string} emailAuthCode Email auth code should be securely generated by your backend server
         * <strong i="18">@param</strong> {Function} callback Handler function for error if it occurred
         */
        public static setEmail(email: string, emailAuthCode: string, callback: (error?: any) => {}): void;

        /**
         * If you don't want to implement email auth hashing on your backend (which is heavily recommended), you can still use the OneSignal email feature in an unauthenticated state with this function.
         * <strong i="19">@param</strong> {string} email User's email address.
         * <strong i="20">@param</strong> {Function} callback Handler function for error if it occurred
         */
        public static setEmail(email: string, callback: (error?: any) => {}): void;

        /**
         * If your application implements logout functionality, you can logout of the OneSignal email for this user using the logout function.
         * <strong i="21">@param</strong> {Function} callback Handler function for error if it occurred
         */
        public static logoutEmail(callback: (error?: any) => {}): void;

        /**
         * You can call this from your UI from a button press for example to give your user's options for your notifications. By default OneSignal always vibrates the device when a notification is displayed unless the device is in a total silent mode. Passing false means that the device will only vibrate lightly when the device is in it's vibrate only mode.
         * <strong i="22">@param</strong> {boolean} setTo New value you want to set.
         */
        public static enableVibrate(setTo: boolean): void;

        /**
         * You can call this from your UI from a button press for example to give your user's options for your notifications. By default OneSignal plays the system's default notification sound when the device's notification system volume is turned on. Passing false means that the device will only vibrate unless the device is set to a total silent mode.
         * <strong i="23">@param</strong> {boolean} setTo New value you want to set.
         */
        public static enableSound(setTo: boolean): void;

        /**
         * You can call this method with false to opt users out of receiving all notifications through OneSignal. You can pass true later to opt users back into notifications
         * <strong i="24">@param</strong> {boolean} setTo New value you want to set.
         */
        public static setSubscription(setTo: boolean): void;

        /**
         * Promts location permission to user.
         */
        public static promptLocation(): void;

        /**
         * Removes all OneSignal notifications from the Notification Shade.
         */
        public static clearOneSignalNotifications(): void;

        /**
         * Disable or enable location collection (defaults to enabled if your app has location permission).
         * <strong i="25">@param</strong> {boolean} setTo New value you want to set.
         */
        public static setLocationShared(setTo: boolean): void;

        /**
         * Prompts the user for location permissions. This allows for geotagging so you can send notifications to users based on location.
         *
         * Note: Make sure you also have the required location permission in your AndroidManifest.xml. For iOS, make sure you set the NSLocationWhenInUseUsageDescription or the NSLocationAlwaysUsageDescription in your info.plist. (Location Always also requires the location background mode capability)
         * <strong i="26">@param</strong> {"react-native-onesignal".InFocusDisplayOption} setTo New value you want to set.
         */
        public static inFocusDisplaying(setTo: InFocusDisplayOption): void;

        /**
         * P2P notification
         * <strong i="27">@param</strong> {object} contents Sample: { en: 'English Message', tr: 'Türkçe Mesaj' }
         * <strong i="28">@param</strong> {Array<any>} data Some array for payload
         * <strong i="29">@param</strong> {string} playerId OneSignal Player Id you want to send message to.
         * <strong i="30">@param</strong> {object} otherParameters Sample: {"ios_attachments" : {"image1" : "{image_url}"}}
         */
        public static postNotification(contents: object, data: Array<any>, playerId: string, otherParameters?: object): void;

        /**
         * Cancels a single OneSignal notification based on its Android notification integer id. You can get the notification Id when invoking OneSignal.onNotificationOpened while receiving a notification.
         * <strong i="31">@param</strong> {string} notificationId Notification id you want to cancel.
         */
        public static cancelNotification( notificationId: string ): void;

        /**
         * See what push permissions are currently enabled. callback will be invoked with a permissions object (currently supported only on iOS).
         * <strong i="32">@param</strong> {Function} callback Callback function you can read the permissions from first parameter.
         */
        public static checkPermissions( callback: (permissions: any) => {}): void;

        /**
         * Requests Push Notification Permissions (iOS Only)
         * <strong i="33">@param</strong> {"react-native-onesignal".Permissions} permissions Permissions you want to ask.
         */
        public static requestPermissions( permissions: Permissions ): void;

        /**
         * Call when you want to prompt the user to accept push notifications. Only call once and only if you passed <strong i="34">@NO</strong> to kOSSettingsKeyAutoPrompt on init.
         */
        public static registerForPushNotifications(): void;

        /**
         * IMPORTANT: Use this function before OneSignal.init
         *
         * Allows you to delay the initialization of the SDK until the user provides privacy consent. The SDK will not be fully initialized until the provideUserConsent(true) method is called.
         *
         * If you set this to be true, the SDK will not fully initialize until consent is provided. You can still call OneSignal methods, but nothing will happen, and the user will not be registered for push notifications.
         * <strong i="35">@param</strong> {boolean} wtf I don't know why this function asking boolean parameter. Just pass true if you don't know what you are doing.
         */
        public static setRequiresUserPrivacyConsent(wtf: boolean): void;

        /**
         * Will initialize the SDK and register for push notifications.
         * <strong i="36">@param</strong> {boolean} wtf I don't know why this function asking boolean parameter. Just pass true if you don't know what you are doing.
         */
        public static provideUserConsent(wtf: boolean): void;

        /**
         * Enable logging to help debug if you run into an issue setting up OneSignal.
         * <strong i="37">@param</strong> {"react-native-onesignal".LogLevel} logLevel Sets the logging level to print to the iOS Xcode log or the Android LogCat log.
         * <strong i="38">@param</strong> {"react-native-onesignal".LogLevel} visualLevel Sets the logging level to show as alert dialogs.
         */
        public static setLogLevel( logLevel: LogLevel, visualLevel: LogLevel ): void;

        /**
         * You can bind events with this function.
         * <strong i="39">@param</strong> {"react-native-onesignal".oneSignalEvents} type Event type you want to subscribe
         * <strong i="40">@param</strong> {Function} handler Handler function
         */
        public static addEventListener(type: oneSignalEvents, handler: Function): void;

        /**
         * You can remove binded events with this function.
         * <strong i="41">@param</strong> {"react-native-onesignal".oneSignalEvents} type Event type you want to subscribe
         * <strong i="42">@param</strong> {Function} handler (Optional) Handler function for solo remove.
         */
        public static removeEventListener(type: oneSignalEvents, handler?: Function): void;
    }
}

@centrual Merci beaucoup !

Madame, Monsieur; J'ai soumis ceci au dépôt DefinitelyTyped.
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/30858

@FabianMeul Merci d'avoir fait l'effort ! Cela semble être en attente avec quelques modifications simples. Allez-vous suivre cela bientôt ou devriez-vous télécharger le fichier depuis votre RP ?

@centrual merci mec

@centrual pouvez-vous s'il vous plaît faire un PR et ajouter les saisies directement à la bibliothèque.

Pourquoi est-il fermé ? OneSignal va-t-il un jour ajouter la prise en charge des scripts dactylographiés ?

Suite à la question @chasemac

Un "non" est une réponse valide :)
Je pense que nous voulons tous savoir si nous pourrons nous fier aux types de ce package ou non.

D'autant plus qu'il s'agit de l'intégration d'une société tierce à but lucratif.
Merci

@sospedra il a été réouvert !

@rgomezp besoin d'aide ?

@sospedra ,
Toujours. N'hésitez pas à ouvrir une pull request pour examen

@rgomezp Je sais que vous devez gérer une entreprise et vous concentrer sur votre

Le problème avec l'approche « soumettre un RP » est que nous gérons également nos propres entreprises et que le processus de va-et-vient pour obtenir l'approbation du RP n'est pas rentable.

MISE À JOUR : j'ai créé la branche typescript-typings où la communauté peut aider à créer les saisies pour le SDK. Merci pour les contributions de tous !

Branche : https://github.com/OneSignal/react-native-onesignal/tree/typescript-typings

PR définitivement typé : https://github.com/DefinitelyTyped/DefinitelyTyped/pull/30858

-----(modifier) ​​je pense que c'est obsolète ------

J'ai dû modifier (le addEventListener et les paramètres) de DefinitelyTyped/DefinitelyTyped#30858 pour que cela fonctionne, mais je ne veux pas passer par toute la bureaucratie impliquée dans un pr.

@rgomezp

Si quelqu'un veut un copypasta c'est ici

// Type definitions for react-native-onesignal 3.2
// Project: https://github.com/geektimecoil/react-native-onesignal#readme
// Definitions by: Krystof Celba <https://github.com/krystofcelba>
//                 Fabian Meul <https://github.com/FabianMeul>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
declare module 'react-native-onesignal' {
  export enum InFocusDisplayOption {
    none = 0,
    inAppAlert = 1,
    notification = 2,
  }

  export enum LogLevel {
    None = 0,
    Fatal = 1,
    Errors = 2,
    Warnings = 3,
    Info = 4,
    Debug = 5,
    Verbose = 6,
  }

  export type oneSignalEvents = 'received' | 'opened' | 'ids';

  export interface Settings {
    kOSSettingsKeyAutoPrompt?: boolean;
    kOSSettingsKeyInAppLaunchURL?: boolean;
    kOSSSettingsKeyPromptBeforeOpeningPushURL?: boolean;
    kOSSettingsKeyInFocusDisplayOption?: InFocusDisplayOption;
  }

  export interface PushData {
    notificationID: string;
    contentAvailable: boolean;
    badge?: number;
    sound: string;
    title: string;
    body: string;
    launchURL?: string;
    additionalData?: any;
    p2p_notification?: any[];
  }

  export interface OpenResult {
    notification: {
      payload: PushData;
      isAppInFocus: boolean;
    };
  }

  export interface Permissions {
    alert: boolean;
    badge: boolean;
    sound: boolean;
  }

  /**
   * shown If the notification was displayed to the user or not
   * payload the push data
   * displayType The display method of a received notification
   * silentNotification Wether the received notification was a silent one
   */
  export interface ReceivedNotification {
    shown: boolean;
    payload: PushData;
    displayType: InFocusDisplayOption;
    silentNotification: boolean;
  }

  export interface OneSignal {
    /**
     * Initialize Onesignal
     */
    init(appId: string, settings?: Settings): void;

    /**
     * Undocumented function.
     */
    Configure(undocumentedParam1?: any, undocumentedParam2?: any): void;

    /**
     * You can set tag for user with this function.
     */
    sendTag(key: string, value: string): void;

    /**
     * You can set multiple tags for user with this function.
     */
    sendTags(tags: object): void;

    /**
     * Getting the tags from the server and use the received object
     */
    getTags(handler: (receivedTags: any) => {}): void;

    /**
     * Allows you to check whether notifications are enabled for the app, whether user is subscribed to notifications through OneSignal,and what the user's in-app subscription preference is.
     * It also provides access to pushToken and userId
     */
    getPermissionSubscriptionState(handler: (status: any) => {}): void;

    /**
     * You can delete tag from user with this function.
     */
    deleteTag(key: string): void;

    /**
     * OneSignal now allows you to send emails to your userbase. This email can be set using the OneSignal react-native SDK.
     */
    setEmail(
      email: string,
      emailAuthCode: string,
      callback: (error?: any) => {},
    ): void;

    /**
     * If you don't want to implement email auth hashing on your backend (which is heavily recommended), you can still use the OneSignal email feature in an unauthenticated state with this function.
     */
    setEmail(email: string, callback: (error?: any) => {}): void;

    /**
     * If your application implements logout functionality, you can logout of the OneSignal email for this user using the logout function.
     */
    logoutEmail(callback: (error?: any) => {}): void;

    /**
     * You can call this from your UI from a button press for example to give your user's options for your notifications.
     * By default OneSignal always vibrates the device when a notification is displayed unless the device is in a total silent mode.
     * Passing false means that the device will only vibrate lightly when the device is in it's vibrate only mode.
     */
    enableVibrate(setTo: boolean): void;

    /**
     * You can call this from your UI from a button press for example to give your user's options for your notifications.
     * By default OneSignal plays the system's default notification sound when the device's notification system volume is turned on.
     * Passing false means that the device will only vibrate unless the device is set to a total silent mode.
     */
    enableSound(setTo: boolean): void;

    /**
     * You can call this method with false to opt users out of receiving all notifications through OneSignal.
     * You can pass true later to opt users back into notifications
     */
    setSubscription(setTo: boolean): void;

    /**
     * Promts location permission to user.
     */
    promptLocation(): void;

    /**
     * Removes all OneSignal notifications from the Notification Shade.
     */
    clearOneSignalNotifications(): void;

    /**
     * Disable or enable location collection (defaults to enabled if your app has location permission).
     */
    setLocationShared(setTo: boolean): void;

    /**
     * Prompts the user for location permissions. This allows for geotagging so you can send notifications to users based on location.
     *
     * Note: Make sure you also have the required location permission in your AndroidManifest.xml.
     * For iOS, make sure you set the NSLocationWhenInUseUsageDescription or the NSLocationAlwaysUsageDescription in your info.plist.
     * (Location Always also requires the location background mode capability)
     */
    inFocusDisplaying(setTo: InFocusDisplayOption): void;

    /**
     * P2P notification
     */
    postNotification(
      contents: object,
      data: any[],
      playerId: string,
      otherParameters?: object,
    ): void;

    /**
     * Cancels a single OneSignal notification based on its Android notification integer id.
     * You can get the notification Id when invoking OneSignal.onNotificationOpened while receiving a notification.
     */
    cancelNotification(notificationId: string): void;

    /**
     * See what push permissions are currently enabled. callback will be invoked with a permissions object (currently supported only on iOS).
     */
    checkPermissions(callback: (permissions: any) => {}): void;

    /**
     * Requests Push Notification Permissions (iOS Only)
     */
    requestPermissions(permissions: Permissions): void;

    /**
     * Call when you want to prompt the user to accept push notifications. Only call once and only if you passed <strong i="11">@NO</strong> to kOSSettingsKeyAutoPrompt on init.
     */
    registerForPushNotifications(): void;

    /**
     * IMPORTANT: Use this function before OneSignal.init
     *
     * Allows you to delay the initialization of the SDK until the user provides privacy consent. The SDK will not be fully initialized until the provideUserConsent(true) method is called.
     *
     * If you set this to be true, the SDK will not fully initialize until consent is provided.
     * You can still call OneSignal methods, but nothing will happen, and the user will not be registered for push notifications.
     */
    setRequiresUserPrivacyConsent(wtf: boolean): void;

    /**
     * Will initialize the SDK and register for push notifications.
     */
    provideUserConsent(wtf: boolean): void;

    /**
     * Enable logging to help debug if you run into an issue setting up OneSignal.
     */
    setLogLevel(logLevel: LogLevel, visualLevel: LogLevel): void;

    /**
     * You can bind events with this function.
     */
    addEventListener(
      type: 'received',
      handler: (notification: ReceivedNotification) => void,
    ): void;
    addEventListener(
      type: 'opened',
      handler: (result: OpenResult) => void,
    ): void;
    addEventListener(type: 'ids', handler: (device: string) => void): void;

    /**
     * You can remove binded events with this function.
     */
    removeEventListener(
      type: 'received',
      handler: (notification: ReceivedNotification) => void,
    ): void;
    removeEventListener(
      type: 'opened',
      handler: (result: OpenResult) => void,
    ): void;
    removeEventListener(type: 'ids', handler: (device: string) => void): void;
  }

  const OneSignal: OneSignal;

  export default OneSignal;
}

Pourquoi n'est-il pas fourni par défaut avec l'installation de npm ? On ne peut pas avoir ça bientôt ?
TS est ce que nous utilisons quotidiennement

Pour ceux qui se demandent, ces saisies ne semblent plus à jour, alors n'y allez pas et faites-leur confiance aveuglément

Y a-t-il une mise à jour sur le moment où nous pourrions nous attendre à ce que les types fassent partie du package @rgomezp ? Je pense qu'il y a beaucoup de gens qui créent des applications RN basées sur TS et ce serait formidable de l'ajouter et de le maintenir avec le package. Merci!

Salut @taschik ,
Je travaille actuellement sur les types (voir branche types ) qui feront partie de la prochaine version majeure.

C'est génial! Merci @rgomezp pour le bon travail et la mise à jour rapide. ??

PSA : la branche types a été fusionnée en major-release .

S'il vous plaît jeter un oeil à #1079 et fournir des commentaires ou signaler tout problème avec les saisies si vous en rencontrez.

Salut,
Les dactylographies sont maintenant disponibles dans le cadre de la version beta.4 .

"dependencies": {
    "react-native-onesignal": "^4.0.0-beta.4"
}

En savoir plus sur la bêta ici .

Prendre plaisir!

Cette page vous a été utile?
0 / 5 - 0 notes