Skip to content
This repository was archived by the owner on Mar 3, 2020. It is now read-only.
Open
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
6 changes: 5 additions & 1 deletion CHANGELOG-iOS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Facebook In-App Notifications for iOS Changelog

## [1.0.2] - 2016-12-09
### Added
- Added support for loading images using SDWebImage instead of using the internal cache loader

## [1.0.1] - 2016-05-10

### Added
Expand All @@ -18,4 +22,4 @@ View all issues and pull requests associated with this release [here](https://gi

Initial Release

[1.0.1]: (https://github.com/facebook/FBNotifications/releases/tag/ios-1.0.1)
[1.0.1]: (https://github.com/facebook/FBNotifications/releases/tag/ios-1.0.1)
8 changes: 5 additions & 3 deletions FBNotifications.podspec
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
Pod::Spec.new do |s|
s.name = 'FBNotifications'
s.version = '1.0.1'
s.version = '1.0.2'
s.license = { :type => 'Facebook Platform License', :file => 'LICENSE' }
s.summary = 'Facebook In-App Notifications Framework'
s.homepage = 'https://developers.facebook.com/products/analytics'
s.authors = { 'Nikita Lutsenko' => 'nlutsenko@me.com' }

s.source = { :git => 'https://github.com/facebook/FBNotifications.git', :tag => s.version.to_s }
s.source = { :git => 'https://github.com/MobileConcepts/FBNotifications.git', :tag => s.version.to_s }

s.requires_arc = true

s.dependency 'SDWebImage'

s.ios.deployment_target = '8.0'

s.source_files = 'iOS/FBNotifications/FBNotifications/**/*.{h,m}'
s.public_header_files = 'iOS/FBNotifications/FBNotifications/*.h'

s.frameworks = 'ImageIO', 'MobileCoreServices'
s.frameworks = 'ImageIO', 'MobileCoreServices','SDWebImage'
end
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,19 @@ - (NSData *)cachedDataForContentURL:(NSURL *)url {
}

- (BOOL)hasCachedContentForURLs:(nullable NSSet<NSURL *> *)urls {
#if __has_include(<SDWebImage/UIImageView+WebCache.h>)
//We let SDWebImage handle the caching
return YES;
#else

for (NSURL *url in urls) {
NSString *cacheKey = [self _cacheKeyForContentURL:url];
if (![self _hasCachedDataForContentWithCacheKey:cacheKey]) {
return NO;
}
}
return YES;
#endif
}

- (BOOL)_hasCachedDataForContentWithCacheKey:(NSString *)key {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ extern NSString *const FBNImageAssetType;
@interface FBNImageAsset : NSObject <FBNAsset>

@property (nonatomic, strong, readonly) UIImage *image;
@property (nonatomic, strong, readonly) NSURL *url;

- (instancetype)initWithImage:(UIImage *)image;
- (instancetype)initWithURL:(NSURL *)url;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ - (instancetype)initWithImage:(UIImage *)image {

return self;
}
- (instancetype)initWithURL:(NSURL *)url {
self = [super init];
if (!self) return self;


_url = url;

return self;
}

///--------------------------------------
#pragma mark - FBNAsset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,19 @@ - (void)loadAssetFromDictionary:(NSDictionary *)dictionary
}

NSURL *url = [NSURL URLWithString:dictionary[@"url"]];
#if __has_include(<SDWebImage/UIImageView+WebCache.h>)
//We let SDWebImage handle the caching
FBNImageAsset *asset = [[FBNImageAsset alloc] initWithURL:url];
completion(asset);

#else
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
NSData *data = [cache cachedDataForContentURL:url];
UIImage *image = [[UIImage alloc] initWithData:data];
FBNImageAsset *asset = [[FBNImageAsset alloc] initWithImage:image];
completion(asset);
});
#endif
}

- (nullable NSSet<NSURL *> *)cacheURLsForAssetDictionary:(NSDictionary *)dictionary {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

#import "FBNImageAsset.h"

#if __has_include(<SDWebImage/UIImageView+WebCache.h>)
#import <SDWebImage/UIImageView+WebCache.h>
#endif

NS_ASSUME_NONNULL_BEGIN

@interface FBNImageAssetViewController ()
Expand Down Expand Up @@ -48,7 +52,13 @@ - (instancetype)initWithAsset:(FBNImageAsset *)asset {
///--------------------------------------

- (void)loadView {
#if __has_include(<SDWebImage/UIImageView+WebCache.h>)
UIImageView *view = [[UIImageView alloc] init];
[view setShowActivityIndicatorView:YES];
[view sd_setImageWithPreviousCachedImageWithURL:self.asset.url placeholderImage:nil options:0 progress:nil completed:nil];
#else
UIImageView *view = [[UIImageView alloc] initWithImage:self.asset.image];
#endif
view.contentMode = UIViewContentModeScaleAspectFill;
self.view = view;
}
Expand Down