React-native-onesignal: الكتابة المطبوعة

تم إنشاؤها على ٣ أبريل ٢٠١٨  ·  23تعليقات  ·  مصدر: OneSignal/react-native-onesignal

مرحبًا يا شباب ، عمل رائع ، هل يمكنكم من فضلك إضافة دعم الكتابة المطبوعة؟

أنا أعمل في مشروع باستخدام الكتابة المطبوعة ، لكنك لا تدعمها :(

Enhancement / Feature

التعليق الأكثر فائدة

مرحبا @ DavidNorena

يمكنك إضافة هذه الكتابة إلى مشروعك يدويًا:

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;
    }
}

ال 23 كومينتر

أنا أيضًا ، ألا تعمل الإشارات التي تعمل على الكتابة الأصلية؟

sionnita ، يمكنك استخدامه داخل الملفات المطبوعة (.tsx ، .ts) ، باستخدام جافا سكريبت vainilla ، كما هو موضح في المستندات ، لكنك ستفقد كتابة IDE ودعم الإكمال التلقائي! وإذا كنت تستخدم tslint ، فستواجه الكثير من الأخطاء والتحذيرات ، ولهذا طلبت ملف التعريفات.

لم أختبرها بعد ، لكن يبدو أن كتابة TypeScript ، لكنني أعتقد أنه غير مكتمل أو غير متوافق لأن طلب السحب بالكامل لم يكن ' ر جعله رئيس الفرع لهذا السبب .

ربما يمكن أن يساعدنا @ krystofcelba أو أي شخص آخر في سحب الطلب فقط من ملف التعريفات المطبوعة ، سأفعل ذلك ولكن ليس لدي الوقت الآن للقيام بذلك :(

يوم جيد يا رفاق!

مرحبا @ DavidNorena

يمكنك إضافة هذه الكتابة إلى مشروعك يدويًا:

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 شكرا جزيلا لك!

إلي من يهمه الامر؛ لقد قدمت هذا إلى ريبو DefinitelyTyped.
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/30858

FabianMeul شكرا لبذل الجهد! يبدو أن هذا معلق مع بعض التعديلات البسيطة. هل ستتابع هذا قريبًا ، أم يجب عليك تنزيل الملف من ملفك الشخصي؟

centrual شكرا لك يا رجل

centrual ، هل يمكنك من فضلك إجراء

لماذا تم إغلاقه؟ هل سيضيف OneSignal دعمًا مطبوعًا؟

متابعة سؤال

الإجابة "لا" هي إجابة صحيحة :)
أعتقد أننا جميعًا نريد فقط معرفة ما إذا كنا سنكون قادرين على الاعتماد على أنواع هذه الحزمة أم لا.

خاصة إذا أخذنا في الاعتبار أن هذا هو تكامل شركة ربحية خارجية.
شكرا 🙆‍♂

sospedra تم إعادة فتحه!

rgomezp بحاجة الى اي مساعدة؟

sospedra ،
دائما. لا تتردد في فتح طلب سحب للمراجعة

rgomezp ، أعلم أنك بحاجة إلى إدارة عمل تجاري والتركيز على تدفق الإيرادات (بينما تدعم في نفس الوقت مئات الآلاف من الحسابات المجانية) ولكن هل يمكنك تسهيل / الإشراف على برنامج المكافآت حتى يتمكن المجتمع من تقديم 5 دولارات تمويل العمل؟ أنا متأكد من أن لديك ما لا يقل عن 1K من مستخدمي Typescript الذين سيشاركون.

تكمن المشكلة في نهج "إرسال العلاقات العامة" في أننا ندير أيضًا أعمالنا التجارية الخاصة ، كما أن عملية الحصول على تصريح الإقامة الدائم لا تعتبر فعالة من حيث التكلفة / الوقت.

تحديث: لقد أنشأت الفرع typescript-typings حيث يمكن للمجتمع أن يساعد في إنشاء كتابات لـ SDK. شكرا لمساهمات الجميع!

الفرع: https://github.com/OneSignal/react-native-onesignal/tree/typescript-typings

بالتأكيد العلاقات العامة المكتوبة: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/30858

----- (عدل) أعتقد أن هذا قديم ------

اضطررت إلى تعديل (addEventListener والإعدادات) من DefinitelyTyped / DefinitelyTyped # 30858 لتشغيله ، لكنني لا أريد الخوض في كل البيروقراطية المتضمنة في العلاقات العامة.

تضمين التغريدة

إذا كان أي شخص يريد copypasta هنا فهو

// 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;
}

لماذا لا يأتي بشكل افتراضي مع تثبيت npm فقط؟ ألا يمكننا الحصول على ذلك قريبًا؟
TS هو ما نستخدمه يوميًا

بالنسبة لأي شخص يتساءل ، لا تبدو هذه الكتابة محدثة بعد الآن ، لذلك لا تذهب وتثق بها بشكل أعمى

هل هناك أي تحديث حول الوقت الذي يمكن أن نتوقع فيه أن تكون الأنواع جزءًا من الحزمة rgomezp ؟ أعتقد أن هناك الكثير من الأشخاص يقومون ببناء تطبيقات RN القائمة على TS وسيكون من الرائع إضافة هذا والحفاظ عليه مع الحزمة. شكرا لك!

مرحبا taschik ،
أنا أعمل حاليًا على الأنواع (انظر الفرع types ) والتي ستكون جزءًا من الإصدار الرئيسي القادم.

هذا رائع! شكرا لك rgomezp على العمل الجيد والتحديث السريع. 👏

PSA: تم دمج الفرع types في major-release .

يرجى إلقاء نظرة على # 1079 وتقديم ملاحظات أو الإبلاغ عن أي مشاكل في الكتابة إذا واجهت أيًا منها.

مرحبًا ،
تتوفر الآن النسخ كجزء من إصدار beta.4 .

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

تعرف على المزيد حول Beta هنا .

يتمتع!

هل كانت هذه الصفحة مفيدة؟
0 / 5 - 0 التقييمات