Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong type definition of OneSignal.postNotification() jsonData parameter #757

Closed
dmitry-salnikov opened this issue Dec 11, 2021 · 1 comment

Comments

@dmitry-salnikov
Copy link

dmitry-salnikov commented Dec 11, 2021

OneSignal Cordova SDK version 3.0.1

The type definition says that notification data is passed as string:

/**
* Send a notification
* @param {string} notificationObjectString - JSON string payload (see REST API reference)
* @param {(success:object)=>void} onSuccess
* @param {(failure:object)=>void} onFailure
* @returns void
*/
postNotification(notificationObjectString: string, onSuccess?: (success: object) => void, onFailure?: (failure: object) => void): void;

However, the iOS native code expects NSDictionary

- (void)postNotification:(CDVInvokedUrlCommand*)command {
postNotificationCallbackId = command.callbackId;
[OneSignal postNotification:command.arguments[0]

OneSignal.postNotification definition (OneSignal iOS SDK v3.9.1 as mentioned in release notes of OneSignal Cordova SDK v3.0.1):

https://github.com/OneSignal/OneSignal-iOS-SDK/blob/fd06483b314f842c16e0a6f74dfb27a04dc7df66/iOS_SDK/OneSignalSDK/Source/OneSignal.h#L502-L504

#pragma mark Post Notification
+ (void)postNotification:(NSDictionary* _Nonnull)jsonData;
+ (void)postNotification:(NSDictionary* _Nonnull)jsonData onSuccess:(OSResultSuccessBlock _Nullable)successBlock onFailure:(OSFailureBlock _Nullable)failureBlock;

Could you please fix this type definition?

@nan-li
Copy link
Contributor

nan-li commented Apr 25, 2022

Thank you for reporting this @dmitry-salnikov,

We are making some typescript changes and this definition will be fixed.

nan-li added a commit that referenced this issue Jun 28, 2022
* Our type file says users should pass an object string to `OneSignal. postNotification`
* but in iOS we are calling `postNotification` - the iOS native code expects `NSDictionary`
* Instead use native `postNotificationWithJsonString`, which is what react native onesignal SDK also uses
* #757
nan-li added a commit that referenced this issue Jun 29, 2022
* Our type file says users should pass an object string to `OneSignal. postNotification`

* but in iOS we are calling `postNotification` - so the iOS native code expects `NSDictionary`

* Instead, let's use the native method `postNotificationWithJsonString`, which is what react native SDK also uses

* #757
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants