-
Notifications
You must be signed in to change notification settings - Fork 0
/
RENAMETHISContactPhotoProvider.m
25 lines (19 loc) · 1.31 KB
/
RENAMETHISContactPhotoProvider.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#import "RENAMETHISContactPhotoProvider.h"
@implementation RENAMETHISContactPhotoProvider
- (DDNotificationContactPhotoPromiseOffer *)contactPhotoPromiseOfferForNotification:(DDUserNotification *)notification {
UIImage *image = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/Dynastic/ShortLook/icon.png"];
// There are two ways to return an image. Asynchronously (if it might take a while) and synchronously (instant).
// Read the docs for more information.
// Asynchronous method:
DDNotificationContactPhotoPromiseOffer *offer = [[NSClassFromString(@"DDNotificationContactPhotoPromiseOffer") alloc] initWithPhotoIdentifier:@"fantastic-unique-identifier"];
[offer fulfillWithBlock:^(DDNotificationContactPhotoPromise *promise) {
promise.backgroundColor = [UIColor yellowColor]; // you can optionally provide a background colour in the case of partially transparent images
[NSThread sleepForTimeInterval:0.5]; // wait half a second to simulate server call
[promise resolveWithImage:image];
// if failed? -> [promise reject];
}];
return offer;
// Synchronous method:
return [NSClassFromString(@"DDNotificationContactPhotoPromiseOffer") offerInstantlyResolvingPromiseWithPhotoIdentifier:@"super-unique-identifier" image:image];
}
@end