summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-10-18 23:09:39 +0300
committerGravatar Vitaly Takmazov2018-10-18 23:09:39 +0300
commitebd483ee5880131d6602e63ca46cfa49caef2983 (patch)
tree71bf2959f44189f2bee743b9fb803ebb210d88d7
parent0b32db6c12b5a01c8d1b6e2e8f0d3089c4aa2ae8 (diff)
Avatars in notifications
-rw-r--r--Juick.xcodeproj/project.pbxproj163
-rw-r--r--Juick.xcodeproj/xcuserdata/vt.xcuserdatad/xcschemes/xcschememanagement.plist5
-rw-r--r--JuickPush/Info.plist31
-rw-r--r--JuickPush/NotificationService.h13
-rw-r--r--JuickPush/NotificationService.m46
5 files changed, 258 insertions, 0 deletions
diff --git a/Juick.xcodeproj/project.pbxproj b/Juick.xcodeproj/project.pbxproj
index f06323d..f5d9575 100644
--- a/Juick.xcodeproj/project.pbxproj
+++ b/Juick.xcodeproj/project.pbxproj
@@ -34,6 +34,8 @@
774528C21F930C06004D110B /* Attachment.m in Sources */ = {isa = PBXBuildFile; fileRef = 774528C11F930C06004D110B /* Attachment.m */; };
7761133821766A3000D350CD /* ContentLoadingCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 7761133621766A3000D350CD /* ContentLoadingCell.m */; };
7761133921766A3000D350CD /* ContentLoadingCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7761133721766A3000D350CD /* ContentLoadingCell.xib */; };
+ 7761135921790B0300D350CD /* NotificationService.m in Sources */ = {isa = PBXBuildFile; fileRef = 7761135821790B0300D350CD /* NotificationService.m */; };
+ 7761135D21790B0300D350CD /* JuickPush.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 7761135521790B0200D350CD /* JuickPush.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
776C41BD1FD3EF180063B82E /* MessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 776C41BB1FD3EF180063B82E /* MessageCell.m */; };
776C41BE1FD3EF180063B82E /* MessageCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 776C41BC1FD3EF180063B82E /* MessageCell.xib */; };
776C41C11FD3FF6E0063B82E /* DiscoverViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 776C41C01FD3FF6E0063B82E /* DiscoverViewController.m */; };
@@ -57,6 +59,30 @@
77FCADDF1D6A50DA00CBA649 /* APIClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 77FCADDE1D6A50DA00CBA649 /* APIClient.m */; };
/* End PBXBuildFile section */
+/* Begin PBXContainerItemProxy section */
+ 7761135B21790B0300D350CD /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 77317BA0181BBE8500D60005 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 7761135421790B0200D350CD;
+ remoteInfo = JuickPush;
+ };
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+ 7761136121790B0300D350CD /* Embed App Extensions */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = "";
+ dstSubfolderSpec = 13;
+ files = (
+ 7761135D21790B0300D350CD /* JuickPush.appex in Embed App Extensions */,
+ );
+ name = "Embed App Extensions";
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
/* Begin PBXFileReference section */
22EE2B61A53B73723D255877 /* libPods-Juick.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Juick.a"; sourceTree = BUILT_PRODUCTS_DIR; };
770A428F1E8881CB000B206A /* DeviceRegistration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceRegistration.h; sourceTree = "<group>"; };
@@ -102,6 +128,11 @@
7761133521766A3000D350CD /* ContentLoadingCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContentLoadingCell.h; sourceTree = "<group>"; };
7761133621766A3000D350CD /* ContentLoadingCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ContentLoadingCell.m; sourceTree = "<group>"; };
7761133721766A3000D350CD /* ContentLoadingCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ContentLoadingCell.xib; sourceTree = "<group>"; };
+ 7761135521790B0200D350CD /* JuickPush.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = JuickPush.appex; sourceTree = BUILT_PRODUCTS_DIR; };
+ 7761135721790B0300D350CD /* NotificationService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NotificationService.h; sourceTree = "<group>"; };
+ 7761135821790B0300D350CD /* NotificationService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NotificationService.m; sourceTree = "<group>"; };
+ 7761135A21790B0300D350CD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ 7761136821790C2D00D350CD /* UserNotificationsUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotificationsUI.framework; path = System/Library/Frameworks/UserNotificationsUI.framework; sourceTree = SDKROOT; };
776C41BA1FD3EF180063B82E /* MessageCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MessageCell.h; sourceTree = "<group>"; };
776C41BB1FD3EF180063B82E /* MessageCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MessageCell.m; sourceTree = "<group>"; };
776C41BC1FD3EF180063B82E /* MessageCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MessageCell.xib; sourceTree = "<group>"; };
@@ -158,12 +189,20 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 7761135221790B0200D350CD /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
77317B9F181BBE8500D60005 = {
isa = PBXGroup;
children = (
+ 7761135621790B0300D350CD /* JuickPush */,
77317BAA181BBE8500D60005 /* Frameworks */,
77317BB1181BBE8500D60005 /* Juick */,
77317BA9181BBE8500D60005 /* Products */,
@@ -175,6 +214,7 @@
isa = PBXGroup;
children = (
77317BA8181BBE8500D60005 /* Juick.app */,
+ 7761135521790B0200D350CD /* JuickPush.appex */,
);
name = Products;
sourceTree = "<group>";
@@ -193,6 +233,7 @@
77317BAD181BBE8500D60005 /* CoreGraphics.framework */,
77317BAF181BBE8500D60005 /* UIKit.framework */,
22EE2B61A53B73723D255877 /* libPods-Juick.a */,
+ 7761136821790C2D00D350CD /* UserNotificationsUI.framework */,
);
name = Frameworks;
sourceTree = "<group>";
@@ -284,6 +325,16 @@
path = Helpers;
sourceTree = "<group>";
};
+ 7761135621790B0300D350CD /* JuickPush */ = {
+ isa = PBXGroup;
+ children = (
+ 7761135721790B0300D350CD /* NotificationService.h */,
+ 7761135821790B0300D350CD /* NotificationService.m */,
+ 7761135A21790B0300D350CD /* Info.plist */,
+ );
+ path = JuickPush;
+ sourceTree = "<group>";
+ };
77FFC0151D5FD13C003BD81A /* Views */ = {
isa = PBXGroup;
children = (
@@ -332,16 +383,35 @@
77317BA5181BBE8500D60005 /* Frameworks */,
77317BA6181BBE8500D60005 /* Resources */,
6F2FFD38EF490A735BDA88E5 /* [CP] Copy Pods Resources */,
+ 7761136121790B0300D350CD /* Embed App Extensions */,
);
buildRules = (
);
dependencies = (
+ 7761135C21790B0300D350CD /* PBXTargetDependency */,
);
name = Juick;
productName = Juick;
productReference = 77317BA8181BBE8500D60005 /* Juick.app */;
productType = "com.apple.product-type.application";
};
+ 7761135421790B0200D350CD /* JuickPush */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 7761136021790B0300D350CD /* Build configuration list for PBXNativeTarget "JuickPush" */;
+ buildPhases = (
+ 7761135121790B0200D350CD /* Sources */,
+ 7761135221790B0200D350CD /* Frameworks */,
+ 7761135321790B0200D350CD /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = JuickPush;
+ productName = JuickPush;
+ productReference = 7761135521790B0200D350CD /* JuickPush.appex */;
+ productType = "com.apple.product-type.app-extension";
+ };
/* End PBXNativeTarget section */
/* Begin PBXProject section */
@@ -362,6 +432,11 @@
};
};
};
+ 7761135421790B0200D350CD = {
+ CreatedOnToolsVersion = 10.0;
+ DevelopmentTeam = KH4MX79ZK7;
+ ProvisioningStyle = Automatic;
+ };
};
};
buildConfigurationList = 77317BA3181BBE8500D60005 /* Build configuration list for PBXProject "Juick" */;
@@ -378,6 +453,7 @@
projectRoot = "";
targets = (
77317BA7181BBE8500D60005 /* Juick */,
+ 7761135421790B0200D350CD /* JuickPush */,
);
};
/* End PBXProject section */
@@ -404,6 +480,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 7761135321790B0200D350CD /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
@@ -484,8 +567,24 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 7761135121790B0200D350CD /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 7761135921790B0300D350CD /* NotificationService.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXSourcesBuildPhase section */
+/* Begin PBXTargetDependency section */
+ 7761135C21790B0300D350CD /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 7761135421790B0200D350CD /* JuickPush */;
+ targetProxy = 7761135B21790B0300D350CD /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
/* Begin PBXVariantGroup section */
77317BB4181BBE8500D60005 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
@@ -642,6 +741,61 @@
};
name = Release;
};
+ 7761135E21790B0300D350CD /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ DEVELOPMENT_TEAM = KH4MX79ZK7;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ INFOPLIST_FILE = JuickPush/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 12.0;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
+ MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
+ MTL_FAST_MATH = YES;
+ PRODUCT_BUNDLE_IDENTIFIER = com.juick.Juick.JuickPush;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SKIP_INSTALL = YES;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ 7761135F21790B0300D350CD /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ INFOPLIST_FILE = JuickPush/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 12.0;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
+ MTL_ENABLE_DEBUG_INFO = NO;
+ MTL_FAST_MATH = YES;
+ PRODUCT_BUNDLE_IDENTIFIER = com.juick.Juick.JuickPush;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SKIP_INSTALL = YES;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Release;
+ };
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
@@ -663,6 +817,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ 7761136021790B0300D350CD /* Build configuration list for PBXNativeTarget "JuickPush" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 7761135E21790B0300D350CD /* Debug */,
+ 7761135F21790B0300D350CD /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
/* End XCConfigurationList section */
};
rootObject = 77317BA0181BBE8500D60005 /* Project object */;
diff --git a/Juick.xcodeproj/xcuserdata/vt.xcuserdatad/xcschemes/xcschememanagement.plist b/Juick.xcodeproj/xcuserdata/vt.xcuserdatad/xcschemes/xcschememanagement.plist
index 52d2f29..1d35997 100644
--- a/Juick.xcodeproj/xcuserdata/vt.xcuserdatad/xcschemes/xcschememanagement.plist
+++ b/Juick.xcodeproj/xcuserdata/vt.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -9,6 +9,11 @@
<key>orderHint</key>
<integer>0</integer>
</dict>
+ <key>JuickPush.xcscheme</key>
+ <dict>
+ <key>orderHint</key>
+ <integer>13</integer>
+ </dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
diff --git a/JuickPush/Info.plist b/JuickPush/Info.plist
new file mode 100644
index 0000000..935f4fa
--- /dev/null
+++ b/JuickPush/Info.plist
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
+ <key>CFBundleDisplayName</key>
+ <string>JuickPush</string>
+ <key>CFBundleExecutable</key>
+ <string>$(EXECUTABLE_NAME)</string>
+ <key>CFBundleIdentifier</key>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>$(PRODUCT_NAME)</string>
+ <key>CFBundlePackageType</key>
+ <string>XPC!</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>NSExtension</key>
+ <dict>
+ <key>NSExtensionPointIdentifier</key>
+ <string>com.apple.usernotifications.service</string>
+ <key>NSExtensionPrincipalClass</key>
+ <string>NotificationService</string>
+ </dict>
+</dict>
+</plist>
diff --git a/JuickPush/NotificationService.h b/JuickPush/NotificationService.h
new file mode 100644
index 0000000..91ca27a
--- /dev/null
+++ b/JuickPush/NotificationService.h
@@ -0,0 +1,13 @@
+//
+// NotificationService.h
+// JuickPush
+//
+// Created by Vitaly Takmazov on 18/10/2018.
+// Copyright © 2018 com.juick. All rights reserved.
+//
+
+#import <UserNotifications/UserNotifications.h>
+
+@interface NotificationService : UNNotificationServiceExtension
+
+@end
diff --git a/JuickPush/NotificationService.m b/JuickPush/NotificationService.m
new file mode 100644
index 0000000..82dead8
--- /dev/null
+++ b/JuickPush/NotificationService.m
@@ -0,0 +1,46 @@
+//
+// NotificationService.m
+// JuickPush
+//
+// Created by Vitaly Takmazov on 18/10/2018.
+// Copyright © 2018 com.juick. All rights reserved.
+//
+
+#import "NotificationService.h"
+
+@interface NotificationService ()
+
+@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
+@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
+
+@end
+
+@implementation NotificationService
+
+- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
+ self.contentHandler = contentHandler;
+ self.bestAttemptContent = [request.content mutableCopy];
+
+ NSURL *avatarURL = [NSURL URLWithString:request.content.userInfo[@"avatarUrl"]];
+
+ NSURLSession * downloadSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
+
+ [[downloadSession downloadTaskWithURL:avatarURL completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error) {
+ if (!error) {
+ NSError *err = nil;
+ NSString *temporaryDirectory = [NSTemporaryDirectory() stringByAppendingPathComponent:[response suggestedFilename]];
+ [[NSFileManager defaultManager] moveItemAtPath:location.path toPath:temporaryDirectory error:&err];
+ UNNotificationAttachment *avatarAttachment = [UNNotificationAttachment attachmentWithIdentifier:avatarURL.lastPathComponent URL:[NSURL fileURLWithPath:temporaryDirectory] options:nil error:&err];
+ self.bestAttemptContent.attachments = @[avatarAttachment];
+ self.contentHandler(self.bestAttemptContent);
+ }
+ }] resume];
+}
+
+- (void)serviceExtensionTimeWillExpire {
+ // Called just before the extension will be terminated by the system.
+ // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
+ self.contentHandler(self.bestAttemptContent);
+}
+
+@end