Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Parse/PFPurchase.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
#import <StoreKit/StoreKit.h>

#import <Parse/PFConstants.h>
#import <Parse/PFNullability.h>

@class PFProduct;

PF_ASSUME_NONNULL_BEGIN

/*!
`PFPurchase` provides a set of APIs for working with in-app purchases.

Expand Down Expand Up @@ -65,7 +68,7 @@
*/
+ (void)downloadAssetForTransaction:(SKPaymentTransaction *)transaction
completion:(void(^)(NSString *filePath, NSError *error))completion
progress:(PFProgressBlock)progress;
progress:(PF_NULLABLE PFProgressBlock)progress;

/*!
@abstract *Asynchronously* restore completed transactions for the current user.
Expand All @@ -85,6 +88,8 @@

@warning This method will return `nil`, if the purchase wasn't verified or if the asset was not downloaded.
*/
+ (NSString *)assetContentPathForProduct:(PFProduct *)product;
+ (PF_NULLABLE NSString *)assetContentPathForProduct:(PFProduct *)product;

@end

PF_ASSUME_NONNULL_END
52 changes: 28 additions & 24 deletions Parse/PFPush.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

@class PFQuery;

PF_ASSUME_NONNULL_BEGIN

/*!
The `PFPush` class defines a push notification that can be sent from a client device.

Expand All @@ -39,15 +41,15 @@
@param channel The channel to set for this push.
The channel name must start with a letter and contain only letters, numbers, dashes, and underscores.
*/
- (void)setChannel:(NSString *)channel;
- (void)setChannel:(PF_NULLABLE NSString *)channel;

/*!
@abstract Sets the array of channels on which this push notification will be sent.

@param channels The array of channels to set for this push.
Each channel name must start with a letter and contain only letters, numbers, dashes, and underscores.
*/
- (void)setChannels:(NSArray *)channels;
- (void)setChannels:(PF_NULLABLE NSArray *)channels;

/*!
@abstract Sets an installation query to which this push notification will be sent.
Expand All @@ -56,7 +58,7 @@

@param query The installation query to set for this push.
*/
- (void)setQuery:(PFQuery *)query;
- (void)setQuery:(PF_NULLABLE PFQuery *)query;

/*!
@abstract Sets an alert message for this push notification.
Expand All @@ -65,7 +67,7 @@

@param message The message to send in this push.
*/
- (void)setMessage:(NSString *)message;
- (void)setMessage:(PF_NULLABLE NSString *)message;

/*!
@abstract Sets an arbitrary data payload for this push notification.
Expand All @@ -76,7 +78,7 @@

@param data The data to send in this push.
*/
- (void)setData:(NSDictionary *)data;
- (void)setData:(PF_NULLABLE NSDictionary *)data;

/*!
@abstract Sets whether this push will go to Android devices.
Expand Down Expand Up @@ -108,7 +110,7 @@

@param date The time at which the notification should expire.
*/
- (void)expireAtDate:(NSDate *)date;
- (void)expireAtDate:(PF_NULLABLE NSDate *)date;

/*!
@abstract Sets the time interval after which this notification should expire.
Expand Down Expand Up @@ -169,7 +171,7 @@
*/
+ (void)sendPushMessageToChannelInBackground:(NSString *)channel
withMessage:(NSString *)message
block:(PFBooleanResultBlock)block;
block:(PF_NULLABLE PFBooleanResultBlock)block;

/*
@abstract *Asynchronously* send a push message to a channel.
Expand All @@ -185,8 +187,8 @@
*/
+ (void)sendPushMessageToChannelInBackground:(NSString *)channel
withMessage:(NSString *)message
target:(id)target
selector:(SEL)selector;
target:(PF_NULLABLE_S id)target
selector:(PF_NULLABLE_S SEL)selector;

/*!
@abstract Send a push message to a query.
Expand Down Expand Up @@ -223,7 +225,7 @@
*/
+ (void)sendPushMessageToQueryInBackground:(PFQuery *)query
withMessage:(NSString *)message
block:(PFBooleanResultBlock)block;
block:(PF_NULLABLE PFBooleanResultBlock)block;

/*!
@abstract *Synchronously* send this push message.
Expand All @@ -246,7 +248,7 @@
@param block The block to execute.
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`.
*/
- (void)sendPushInBackgroundWithBlock:(PFBooleanResultBlock)block;
- (void)sendPushInBackgroundWithBlock:(PF_NULLABLE PFBooleanResultBlock)block;

/*
@abstract *Asynchronously* send this push message and calls the given callback.
Expand All @@ -257,7 +259,7 @@
`error` will be `nil` on success and set if there was an error.
`[result boolValue]` will tell you whether the call succeeded or not.
*/
- (void)sendPushInBackgroundWithTarget:(id)target selector:(SEL)selector;
- (void)sendPushInBackgroundWithTarget:(PF_NULLABLE_S id)target selector:(PF_NULLABLE_S SEL)selector;

/*!
@abstract *Synchronously* send a push message with arbitrary data to a channel.
Expand Down Expand Up @@ -302,7 +304,7 @@
*/
+ (void)sendPushDataToChannelInBackground:(NSString *)channel
withData:(NSDictionary *)data
block:(PFBooleanResultBlock)block;
block:(PF_NULLABLE PFBooleanResultBlock)block;

/*
@abstract *Asynchronously* send a push message with arbitrary data to a channel.
Expand All @@ -320,8 +322,8 @@
*/
+ (void)sendPushDataToChannelInBackground:(NSString *)channel
withData:(NSDictionary *)data
target:(id)target
selector:(SEL)selector;
target:(PF_NULLABLE_S id)target
selector:(PF_NULLABLE_S SEL)selector;

/*!
@abstract *Synchronously* send a push message with arbitrary data to a query.
Expand Down Expand Up @@ -366,7 +368,7 @@
*/
+ (void)sendPushDataToQueryInBackground:(PFQuery *)query
withData:(NSDictionary *)data
block:(PFBooleanResultBlock)block;
block:(PF_NULLABLE PFBooleanResultBlock)block;

///--------------------------------------
/// @name Handling Notifications
Expand All @@ -384,7 +386,7 @@

@param userInfo The userInfo dictionary you get in `appplication:didReceiveRemoteNotification:`.
*/
+ (void)handlePush:(NSDictionary *)userInfo NS_AVAILABLE_IOS(3_0);
+ (void)handlePush:(PF_NULLABLE NSDictionary *)userInfo NS_AVAILABLE_IOS(3_0);

///--------------------------------------
/// @name Managing Channel Subscriptions
Expand All @@ -407,7 +409,7 @@

@returns Returns an `NSSet` containing all the channel names this device is subscribed to.
*/
+ (NSSet *)getSubscribedChannels:(NSError **)error;
+ (PF_NULLABLE NSSet *)getSubscribedChannels:(NSError **)error;

/*!
@abstract *Asynchronously* get all the channels that this device is subscribed to.
Expand Down Expand Up @@ -464,7 +466,7 @@
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`
*/
+ (void)subscribeToChannelInBackground:(NSString *)channel
block:(PFBooleanResultBlock)block;
block:(PF_NULLABLE PFBooleanResultBlock)block;

/*
@abstract *Asynchronously* subscribes the device to a channel of push notifications and calls the given callback.
Expand All @@ -478,8 +480,8 @@
`[result boolValue]` will tell you whether the call succeeded or not.
*/
+ (void)subscribeToChannelInBackground:(NSString *)channel
target:(id)target
selector:(SEL)selector;
target:(PF_NULLABLE_S id)target
selector:(PF_NULLABLE_S SEL)selector;

/*!
@abstract *Synchronously* unsubscribes the device to a channel of push notifications.
Expand Down Expand Up @@ -508,7 +510,7 @@
It should have the following argument signature: `^(BOOL succeeded, NSError *error)`.
*/
+ (void)unsubscribeFromChannelInBackground:(NSString *)channel
block:(PFBooleanResultBlock)block;
block:(PF_NULLABLE PFBooleanResultBlock)block;

/*
@abstract *Asynchronously* unsubscribes the device from a channel of push notifications and calls the given callback.
Expand All @@ -521,7 +523,9 @@
`[result boolValue]` will tell you whether the call succeeded or not.
*/
+ (void)unsubscribeFromChannelInBackground:(NSString *)channel
target:(id)target
selector:(SEL)selector;
target:(PF_NULLABLE_S id)target
selector:(PF_NULLABLE_S SEL)selector;

@end

PF_ASSUME_NONNULL_END
6 changes: 4 additions & 2 deletions Tests/Unit/PurchaseUnitTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,23 @@ - (void)testAssetContentPath {
PFPurchaseController *mockedPurchaseController = [self mockedPurchaseController];
[Parse _currentManager].purchaseController = mockedPurchaseController;

PFProduct *product = [PFProduct object];

NSString *somePath = [NSTemporaryDirectory() stringByAppendingPathComponent:[[NSUUID UUID] UUIDString]];

OCMStub([mockedPurchaseController assetContentPathForProductWithIdentifier:OCMOCK_ANY
fileName:OCMOCK_ANY]).andReturn(somePath);


XCTAssertNil([PFPurchase assetContentPathForProduct:nil]);
XCTAssertNil([PFPurchase assetContentPathForProduct:product]);

NSError *error;
[@"" writeToFile:somePath atomically:YES
encoding:NSUTF8StringEncoding
error:&error];

XCTAssertNil(error);
XCTAssertNotNil([PFPurchase assetContentPathForProduct:nil]);
XCTAssertNotNil([PFPurchase assetContentPathForProduct:product]);
}

@end