-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Push notifications #27
Merged
+370
−43
Merged
Changes from 4 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
417ebb1
add push notification base code
nplasterer 5e167df
register for pushes
nplasterer 3251ff0
add ability to subscribe to topics
nplasterer c8d4ce1
remove file that won't be used
nplasterer 8f8bb43
getting closer with registering and subscribing
nplasterer 68979c2
add parsing the messages
nplasterer 34c6b35
get the decoding working
nplasterer 8fe0d84
actually send the push
nplasterer 0d5f45a
a few generic tweaks
nplasterer 068f87d
Merge branch 'main' into np/expo-push-test
nplasterer 359cf2c
remove yarn lock file
nplasterer 07d02b3
Merge branch 'np/expo-push-test' of https://github.com/xmtp/xmtp-reac…
nplasterer e9a9ef7
add back packge resolved
nplasterer 5e86051
add a few more items to the read me
nplasterer 1539f60
add iOS boiler plate to keep it from breaking
nplasterer 6bbbc4f
docs: just a few edits
jhaaaa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -1,34 +1,99 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="expo.modules.xmtpreactnativesdk.example"> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> | ||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> | ||
<uses-permission android:name="android.permission.VIBRATE"/> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
<queries> | ||
<intent> | ||
<action android:name="android.intent.action.VIEW"/> | ||
<category android:name="android.intent.category.BROWSABLE"/> | ||
<data android:scheme="https"/> | ||
</intent> | ||
</queries> | ||
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true"> | ||
<meta-data android:name="expo.modules.updates.ENABLED" android:value="true"/> | ||
<meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="48.0.0"/> | ||
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/> | ||
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/> | ||
<meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://exp.host/@anonymous/xmtp-react-native-sdk-example"/> | ||
<activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
<intent-filter> | ||
<action android:name="android.intent.action.VIEW"/> | ||
<category android:name="android.intent.category.DEFAULT"/> | ||
<category android:name="android.intent.category.BROWSABLE"/> | ||
<data android:scheme="expo.modules.xmtpreactnativesdk.example"/> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false"/> | ||
</application> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="expo.modules.xmtpreactnativesdk.example"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> | ||
<uses-permission android:name="android.permission.VIBRATE" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.WAKE_LOCK" /> | ||
<permission | ||
android:name="${applicationId}.permission.C2D_MESSAGE" | ||
android:protectionLevel="signature" /> | ||
|
||
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" /> | ||
<uses-permission android:name="android.permission.VIBRATE" /> | ||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | ||
|
||
<queries> | ||
<intent> | ||
<action android:name="android.intent.action.VIEW" /> | ||
<category android:name="android.intent.category.BROWSABLE" /> | ||
<data android:scheme="https" /> | ||
</intent> | ||
</queries> | ||
<application | ||
android:name=".MainApplication" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:theme="@style/AppTheme" | ||
android:usesCleartextTraffic="true"> | ||
<meta-data | ||
android:name="expo.modules.updates.ENABLED" | ||
android:value="true" /> | ||
<meta-data | ||
android:name="expo.modules.updates.EXPO_SDK_VERSION" | ||
android:value="48.0.0" /> | ||
<meta-data | ||
android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" | ||
android:value="ALWAYS" /> | ||
<meta-data | ||
android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" | ||
android:value="0" /> | ||
<meta-data | ||
android:name="expo.modules.updates.EXPO_UPDATE_URL" | ||
android:value="https://exp.host/@anonymous/xmtp-react-native-sdk-example" /> | ||
|
||
<activity | ||
android:name=".MainActivity" | ||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" | ||
android:exported="true" | ||
android:label="@string/app_name" | ||
android:launchMode="singleTask" | ||
android:screenOrientation="portrait" | ||
android:theme="@style/Theme.App.SplashScreen" | ||
android:windowSoftInputMode="adjustResize"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
<intent-filter> | ||
<action android:name="android.intent.action.VIEW" /> | ||
|
||
<category android:name="android.intent.category.DEFAULT" /> | ||
<category android:name="android.intent.category.BROWSABLE" /> | ||
|
||
<data android:scheme="expo.modules.xmtpreactnativesdk.example" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name="com.facebook.react.devsupport.DevSettingsActivity" | ||
android:exported="false" /> | ||
|
||
<meta-data | ||
android:name="com.dieam.reactnativepushnotification.notification_channel_name" | ||
android:value="YOUR NOTIFICATION CHANNEL NAME" /> | ||
<meta-data | ||
android:name="com.dieam.reactnativepushnotification.notification_channel_description" | ||
android:value="YOUR NOTIFICATION CHANNEL DESCRIPTION" /> | ||
<meta-data | ||
android:name="com.dieam.reactnativepushnotification.notification_color" | ||
android:resource="@android:color/white" /> | ||
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" /> | ||
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.BOOT_COMPLETED" /> | ||
</intent-filter> | ||
</receiver> | ||
<service | ||
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService" | ||
android:exported="false"> | ||
<intent-filter> | ||
<action android:name="com.google.firebase.MESSAGING_EVENT" /> | ||
</intent-filter> | ||
</service> | ||
</application> | ||
</manifest> |
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
14 changes: 0 additions & 14 deletions
14
example/ios/xmtpreactnativesdkexample.xcworkspace/xcshareddata/swiftpm/Package.resolved
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,36 @@ | ||
import { Component } from "react"; | ||
import { PushNotificationIOS } from "react-native/Libraries/PushNotificationIOS/PushNotificationIOS"; | ||
import PushNotification from "react-native-push-notification"; | ||
import { XMTPPush } from "xmtp-react-native-sdk"; | ||
|
||
export default class PushController extends Component { | ||
componentDidMount() { | ||
PushNotification.configure({ | ||
// (optional) Called when Token is generated (iOS and Android) | ||
onRegister(token: any) { | ||
console.log("TOKEN:", token); | ||
XMTPPush.register("10.0.2.2:8080", token); | ||
}, | ||
// (required) Called when a remote or local notification is opened or received | ||
onNotification(notification: { finish: (arg0: any) => void; }) { | ||
console.log("NOTIFICATION:", notification); | ||
// process the notification here | ||
// required on iOS only | ||
notification.finish(PushNotificationIOS.FetchResult.NoData); | ||
}, | ||
// Android only | ||
senderID: "609788839593", | ||
nplasterer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// iOS only | ||
permissions: { | ||
alert: true, | ||
badge: true, | ||
sound: true, | ||
}, | ||
popInitialNotification: true, | ||
requestPermissions: true, | ||
}); | ||
} | ||
render() { | ||
return null; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only subscribes once you refresh the list view. Not super great at react couldn't figure out how to get it to subscribe on streaming conversations but this is a minor detail and we can improve it later.