Skip to content

Commit c513cd8

Browse files
author
Rad Azzouz
committed
Rename addAnnotations to applyInstantJSON
1 parent e6a9778 commit c513cd8

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

CordovaDemo/platforms/ios/www/plugins/pspdfkit-cordova-ios/PSPDFKitPlugin/pspdfkit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ var PSPDFKitPlugin = new function() {
191191

192192
// Instant JSON
193193
addMethods({
194-
addAnnotations: ['jsonAnnotations', 'callback'],
194+
applyInstantJSON: ['jsonValue', 'callback'],
195195
addAnnotation: ['jsonAnnotation', 'callback'],
196196
removeAnnotation: ['jsonAnnotation', 'callback'],
197197
getAnnotations: ['pageIndex', 'type', 'callback'],

PSPDFKitPlugin/PSPDFKitPlugin.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,13 +1502,13 @@ - (void)getAllUnsavedAnnotations:(CDVInvokedUrlCommand *)command {
15021502
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
15031503
}
15041504

1505-
- (void)addAnnotations:(CDVInvokedUrlCommand *)command {
1506-
id jsonAnnotations = [command argumentAtIndex:0];
1505+
- (void)applyInstantJSON:(CDVInvokedUrlCommand *)command {
1506+
id jsonValue = [command argumentAtIndex:0];
15071507
NSData *data;
1508-
if ([jsonAnnotations isKindOfClass:NSString.class]) {
1509-
data = [jsonAnnotations dataUsingEncoding:NSUTF8StringEncoding];
1510-
} else if ([jsonAnnotations isKindOfClass:NSDictionary.class]) {
1511-
data = [NSJSONSerialization dataWithJSONObject:jsonAnnotations options:0 error:nil];
1508+
if ([jsonValue isKindOfClass:NSString.class]) {
1509+
data = [jsonValue dataUsingEncoding:NSUTF8StringEncoding];
1510+
} else if ([jsonValue isKindOfClass:NSDictionary.class]) {
1511+
data = [NSJSONSerialization dataWithJSONObject:jsonValue options:0 error:nil];
15121512
} else {
15131513
NSLog(@"Invalid JSON Annotations.");
15141514
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR]

PSPDFKitPlugin/pspdfkit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ var PSPDFKitPlugin = new function() {
190190

191191
// Instant JSON
192192
addMethods({
193-
addAnnotations: ['jsonAnnotations', 'callback'],
193+
applyInstantJSON: ['jsonValue', 'callback'],
194194
addAnnotation: ['jsonAnnotation', 'callback'],
195195
removeAnnotation: ['jsonAnnotation', 'callback'],
196196
getAnnotations: ['pageIndex', 'type', 'callback'],

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,9 @@ Annotation API
405405

406406
The methods below allows you to programmatically access, add, and remove annotations using the Instant JSON format: https://pspdfkit.com/guides/ios/current/importing-exporting/instant-json/
407407

408-
// Add multiple annotations using an Instant JSON Document payload - https://pspdfkit.com/guides/ios/current/importing-exporting/instant-json/#instant-document-json-api
409-
addAnnotations(jsonAnnotations, [callback]);
408+
// Apply Instant JSON Document payload - https://pspdfkit.com/guides/ios/current/importing-exporting/instant-json/#instant-document-json-api
409+
// Can be used to add annotations, bookmarks, fill forms, etc.
410+
applyInstantJSON(jsonValue, [callback]);
410411

411412
// Add a single annotation using an Instant JSON Annotation payload - https://pspdfkit.com/guides/ios/current/importing-exporting/instant-json/#instant-annotation-json-api
412413
addAnnotation(jsonAnnotation, [callback]);

0 commit comments

Comments
 (0)