Skip to content

Commit

Permalink
[expo-notifications] Implement InstallationIdProvider in TS
Browse files Browse the repository at this point in the history
  • Loading branch information
sjchmiela committed Jan 16, 2020
1 parent 266fde6 commit cf887d9
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/expo-notifications/build/InstallationIdProvider.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/expo-notifications/build/InstallationIdProvider.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions packages/expo-notifications/build/InstallationIdProvider.web.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion packages/expo-notifications/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@
"@unimodules/core": "~5.0.0",
"expo-constants": "~8.0.0"
},
"gitHead": "ec7878b9ce54f2537721218ae0fe4017e4004806"
"gitHead": "ec7878b9ce54f2537721218ae0fe4017e4004806",
"dependencies": {
"@types/uuid-js": "^0.7.2",
"uuid-js": "^0.7.5"
}
}
7 changes: 7 additions & 0 deletions packages/expo-notifications/src/InstallationIdProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { NativeModulesProxy, ProxyNativeModule } from '@unimodules/core';

export interface InstallationIdProvider extends ProxyNativeModule {
getInstallationIdAsync: () => Promise<string>;
}

export default (NativeModulesProxy.NotificationsInstallationIdProvider as any) as InstallationIdProvider;
21 changes: 21 additions & 0 deletions packages/expo-notifications/src/InstallationIdProvider.web.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import UUID from 'uuid-js';

import { InstallationIdProvider } from './InstallationIdProvider';

const INSTALLATION_ID_KEY = '@@expo-notifications.InstallationId@@';

export default {
getInstallationIdAsync: async () => {
let installationId = localStorage.getItem(INSTALLATION_ID_KEY);
if (installationId) {
return installationId;
}

installationId = UUID.create().toString();
localStorage.setItem(INSTALLATION_ID_KEY, installationId);
return installationId;
},
// mock implementations
addListener: () => null,
removeListeners: () => null,
} as InstallationIdProvider;
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2918,7 +2918,7 @@
resolved "https://registry.yarnpkg.com/@types/url-parse/-/url-parse-1.4.3.tgz#fba49d90f834951cb000a674efee3d6f20968329"
integrity sha512-4kHAkbV/OfW2kb5BLVUuUMoumB3CP8rHqlw48aHvFy5tf9ER0AfOonBlX29l/DD68G70DmyhRlSYfQPSYpC5Vw==

"@types/uuid-js@^0.7.1":
"@types/uuid-js@^0.7.1", "@types/uuid-js@^0.7.2":
version "0.7.2"
resolved "https://registry.yarnpkg.com/@types/uuid-js/-/uuid-js-0.7.2.tgz#5b5552fcbaaf4acf026fb6dc66f7e5bd6b4be92f"
integrity sha512-9R+mA6mMXkFVQnXEeX5fMQDR2SYND7cafJTqbeMpLhgsL7qr7MF4ZBxWpLexml3lZsBsyAmqVWbOiB0N10m15w==
Expand Down

0 comments on commit cf887d9

Please sign in to comment.