-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from kanzitelli/notifications
Notifications
- Loading branch information
Showing
20 changed files
with
136 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ build/ | |
local.properties | ||
*.iml | ||
*.hprof | ||
google-services.json | ||
|
||
# Own | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## 🎛 Notifications | ||
|
||
<i>Detailed guide will be published soon...</i> | ||
|
||
Meanwhile, you can check this [tutorial](https://dev.to/jakubkoci/react-native-push-notifications-313i) which helped me to set up and test notifications. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
android/app/src/main/res/drawable-anydpi-v24/notification_icon.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24" | ||
android:tint="#FFFFFF"> | ||
<group android:scaleX="0.92" | ||
android:scaleY="0.92" | ||
android:translateX="0.96" | ||
android:translateY="0.96"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M19,3L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM6,7h5v1.5L6,8.5L6,7zM19,19L5,19L19,5v14zM14.5,16v2L16,18v-2h2v-1.5h-2v-2h-1.5v2h-2L12.5,16z"/> | ||
</group> | ||
</vector> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorAccent">#4D7198</color> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { NotificationBackgroundFetchResult, Notifications as RNNotifications } from 'react-native-notifications'; | ||
|
||
class NotificationsService implements IService { | ||
init = async () => { | ||
// this.registerReactNativeNotifications(); | ||
} | ||
|
||
private registerReactNativeNotifications() { | ||
this.registerDevice() | ||
this.registerNotificationEvents() | ||
} | ||
|
||
private registerDevice() { | ||
RNNotifications.events().registerRemoteNotificationsRegistered(event => { | ||
// TODO: Send the token to my server so it could send back push notifications... | ||
console.log('[RNNotification] Device Token Received', event.deviceToken) | ||
}) | ||
RNNotifications.events().registerRemoteNotificationsRegistrationFailed(event => { | ||
console.error(event) | ||
}) | ||
|
||
RNNotifications.registerRemoteNotifications() | ||
} | ||
|
||
private registerNotificationEvents() { | ||
RNNotifications.events().registerNotificationReceivedForeground((notification, completion) => { | ||
console.log('[RNNotification] Notification Received - Foreground', notification) | ||
|
||
// Calling completion on iOS with `alert: true` will present the native iOS inApp notification. | ||
completion({ alert: false, sound: false, badge: false }) | ||
}) | ||
|
||
RNNotifications.events().registerNotificationOpened((notification, completion) => { | ||
console.log('[RNNotification] Notification opened by device user', notification) | ||
console.log(`[RNNotification] Notification opened with an action identifier: ${notification.identifier}`) | ||
completion() | ||
}) | ||
|
||
// doesn't work for some reason | ||
RNNotifications.events().registerNotificationReceivedBackground((notification, completion) => { | ||
console.log('[RNNotification] Notification Received - Background', notification) | ||
|
||
// Calling completion on iOS with `alert: true` will present the native iOS inApp notification. | ||
completion(NotificationBackgroundFetchResult.NEW_DATA); | ||
}) | ||
|
||
RNNotifications.getInitialNotification() | ||
.then(notification => { | ||
console.log('[RNNotification] Initial notification was:', notification || 'N/A') | ||
}) | ||
.catch(err => console.error('[RNNotification] getInitialNotifiation() failed', err)) | ||
} | ||
} | ||
|
||
export default new NotificationsService(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7966,6 +7966,11 @@ react-native-navigation@^7.6.0: | |
react-lifecycles-compat "2.0.0" | ||
tslib "1.9.3" | ||
|
||
react-native-notifications@^3.4.1: | ||
version "3.4.1" | ||
resolved "https://registry.yarnpkg.com/react-native-notifications/-/react-native-notifications-3.4.1.tgz#3046bae51863e1073d71820598f0b85a3b389535" | ||
integrity sha512-jJHo5z5XR0smZIVj4yjoqDWZ3HX26TL8FMsUIBiIy1Hh9b0q/HAl1xN651sTW/HM49+Mr2F+ShSf6nXBnGB4fQ== | ||
|
||
[email protected]: | ||
version "2.0.0-rc.0" | ||
resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-2.0.0-rc.0.tgz#7a1b0bfd48e3de9dfa985a524463b6a216531358" | ||
|