Skip to content

Commit

Permalink
Use PushNotificationIOS module to get the initial data (#1643)
Browse files Browse the repository at this point in the history
* Link PushNotificationIOS in Xcode

* Use PushNotificationIOS.getInitialNotification() to get initial data
  • Loading branch information
kunall17 authored and borisyankov committed Jan 18, 2018
1 parent 6da3b8c commit bbe5287
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
45 changes: 45 additions & 0 deletions ios/ZulipMobile.xcodeproj/project.pbxproj
Expand Up @@ -28,6 +28,7 @@
197FEFEE99B8469BB155DC40 /* Feather.ttf in Resources */ = {isa = PBXBuildFile; fileRef = CF6D016517D74B509DBD05DC /* Feather.ttf */; };
2318BF63A79049CA9F97E2E0 /* libRNSentry.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B83DDAD2507A4F0EB47660BD /* libRNSentry.a */; };
3556F3DAC2424EBE9ABF0A31 /* Zocial.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 2E41C86FA25744F998C2BB02 /* Zocial.ttf */; };
3C289EE01FF361C9002AF37A /* libRCTPushNotification.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C289E9B1FF3617C002AF37A /* libRCTPushNotification.a */; };
3C4249EB1EF6E09F00D245F1 /* libRNNotifications.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C4249E61EF6E05C00D245F1 /* libRNNotifications.a */; };
48D1FC73615948D79D3BD31E /* Octicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A7F287C57D8A4354A8B6A3E7 /* Octicons.ttf */; };
49692FC0562C40F3946EC6D4 /* Foundation.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A752523B8D8E49E792F653E1 /* Foundation.ttf */; };
Expand Down Expand Up @@ -188,6 +189,20 @@
remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192;
remoteInfo = React;
};
3C289E9A1FF3617C002AF37A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 3C289E861FF3617C002AF37A /* RCTPushNotification.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RCTPushNotification;
};
3C289E9C1FF3617C002AF37A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 3C289E861FF3617C002AF37A /* RCTPushNotification.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 3D05745F1DE6004600184BB4;
remoteInfo = "RCTPushNotification-tvOS";
};
3C4249E51EF6E05C00D245F1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 3C4249C61EF6E05C00D245F1 /* RNNotifications.xcodeproj */;
Expand Down Expand Up @@ -449,6 +464,7 @@
2E41C86FA25744F998C2BB02 /* Zocial.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Zocial.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Zocial.ttf"; sourceTree = "<group>"; };
2E8422FF1CBA4192B7E14D56 /* RNSentry.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNSentry.xcodeproj; path = "../node_modules/react-native-sentry/ios/RNSentry.xcodeproj"; sourceTree = "<group>"; };
3074EDA2D113487A925E187C /* libRNVectorIcons.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNVectorIcons.a; sourceTree = "<group>"; };
3C289E861FF3617C002AF37A /* RCTPushNotification.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTPushNotification.xcodeproj; path = "../node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj"; sourceTree = "<group>"; };
3C4249C61EF6E05C00D245F1 /* RNNotifications.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNNotifications.xcodeproj; path = "../node_modules/react-native-notifications/RNNotifications/RNNotifications.xcodeproj"; sourceTree = "<group>"; };
3C4249EC1EF6E16500D245F1 /* ZulipMobile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = ZulipMobile.entitlements; path = ZulipMobile/ZulipMobile.entitlements; sourceTree = "<group>"; };
51E1EDA028654E17A35C5BCA /* MaterialIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = MaterialIcons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/MaterialIcons.ttf"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -514,6 +530,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
3C289EE01FF361C9002AF37A /* libRCTPushNotification.a in Frameworks */,
A146BE491FDB4C640090EA06 /* libART.a in Frameworks */,
3C4249EB1EF6E09F00D245F1 /* libRNNotifications.a in Frameworks */,
CFCFE5491F00158500C295CF /* libRCTCameraRoll.a in Frameworks */,
Expand Down Expand Up @@ -730,6 +747,15 @@
name = Frameworks;
sourceTree = "<group>";
};
3C289E871FF3617C002AF37A /* Products */ = {
isa = PBXGroup;
children = (
3C289E9B1FF3617C002AF37A /* libRCTPushNotification.a */,
3C289E9D1FF3617C002AF37A /* libRCTPushNotification-tvOS.a */,
);
name = Products;
sourceTree = "<group>";
};
3C4249C71EF6E05C00D245F1 /* Products */ = {
isa = PBXGroup;
children = (
Expand All @@ -750,6 +776,7 @@
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
isa = PBXGroup;
children = (
3C289E861FF3617C002AF37A /* RCTPushNotification.xcodeproj */,
A1E053B01FDB490D002A87B7 /* ART.xcodeproj */,
3C4249C61EF6E05C00D245F1 /* RNNotifications.xcodeproj */,
A14EA8541EACE4CE009D9E83 /* RCTAnimation.xcodeproj */,
Expand Down Expand Up @@ -1047,6 +1074,10 @@
ProductGroup = 0A955E2F1FACB50000801C8D /* Products */;
ProjectRef = 713A523038564C27B0D2C2F7 /* RCTOrientation.xcodeproj */;
},
{
ProductGroup = 3C289E871FF3617C002AF37A /* Products */;
ProjectRef = 3C289E861FF3617C002AF37A /* RCTPushNotification.xcodeproj */;
},
{
ProductGroup = 139105B71AF99BAD00B5F7CC /* Products */;
ProjectRef = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */;
Expand Down Expand Up @@ -1240,6 +1271,20 @@
remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
3C289E9B1FF3617C002AF37A /* libRCTPushNotification.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTPushNotification.a;
remoteRef = 3C289E9A1FF3617C002AF37A /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
3C289E9D1FF3617C002AF37A /* libRCTPushNotification-tvOS.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = "libRCTPushNotification-tvOS.a";
remoteRef = 3C289E9C1FF3617C002AF37A /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
3C4249E61EF6E05C00D245F1 /* libRNNotifications.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
Expand Down
9 changes: 7 additions & 2 deletions ios/ZulipMobile/AppDelegate.m
Expand Up @@ -21,6 +21,7 @@
#import <asl.h>
#import "RCTLog.h"
#import "RNNotifications.h"
#import <React/RCTPushNotificationManager.h>

@implementation AppDelegate

Expand Down Expand Up @@ -118,13 +119,17 @@ - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotif
}

// Required for the notification event.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification {
[RNNotifications didReceiveRemoteNotification:notification];
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
[RNNotifications didReceiveRemoteNotification:userInfo];
[RCTPushNotificationManager didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

// Required for the localNotification event.
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
[RNNotifications didReceiveLocalNotification:notification];
[RCTPushNotificationManager didReceiveLocalNotification:notification];
}
@end
9 changes: 8 additions & 1 deletion src/utils/notifications.ios.js
@@ -1,5 +1,6 @@
/* @flow */
import NotificationsIOS from 'react-native-notifications';
import { PushNotificationIOS } from 'react-native';

import type { Auth, Actions } from '../types';
import { registerPush } from '../api';
Expand Down Expand Up @@ -47,4 +48,10 @@ export const handlePendingNotifications = async (
}
};

export const tryInitialNotification = async (doNarrow: Actions.doNarrow) => {};
export const tryInitialNotification = async (doNarrow: Actions.doNarrow) => {
const data = await PushNotificationIOS.getInitialNotification();
if (data && data.getData) {
handlePendingNotifications(data, doNarrow);
}
};

0 comments on commit bbe5287

Please sign in to comment.