mirror of
https://github.com/balzack/databag.git
synced 2025-04-21 09:05:13 +00:00
integrating unified push
This commit is contained in:
parent
c5ef6be2bb
commit
18e04a9418
@ -18,6 +18,7 @@ import { Access } from 'src/access/Access';
|
||||
import { Dashboard } from 'src/dashboard/Dashboard';
|
||||
import { Session } from 'src/session/Session';
|
||||
import ReceiveSharingIntent from 'react-native-receive-sharing-intent';
|
||||
import {PermissionsAndroid} from 'react-native';
|
||||
|
||||
// silence warning: Sending `onAnimatedValueUpdate` with no listeners registered
|
||||
//LogBox.ignoreLogs(['Sending']);
|
||||
@ -27,6 +28,7 @@ export default function App() {
|
||||
const [sharing, setSharing] = useState();
|
||||
|
||||
useEffect(() => {
|
||||
PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS);
|
||||
ReceiveSharingIntent.getReceivedFiles(files => {
|
||||
setSharing(files);
|
||||
},
|
||||
|
@ -104,7 +104,7 @@ android {
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
versionName "1.5"
|
||||
}
|
||||
|
||||
splits {
|
||||
@ -115,14 +115,16 @@ android {
|
||||
include (*reactNativeArchitectures())
|
||||
}
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
debug {
|
||||
storeFile file('debug.keystore')
|
||||
storePassword 'android'
|
||||
keyAlias 'androiddebugkey'
|
||||
keyPassword 'android'
|
||||
}
|
||||
release {
|
||||
storeFile file('balzack.keystore')
|
||||
storePassword 'balzack'
|
||||
keyAlias 'balzack'
|
||||
keyPassword 'balzack'
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
signingConfig signingConfigs.debug
|
||||
@ -130,7 +132,7 @@ android {
|
||||
release {
|
||||
// Caution! In production, you need to generate your own keystore file.
|
||||
// see https://reactnative.dev/docs/signed-apk-android.
|
||||
signingConfig signingConfigs.debug
|
||||
signingConfig signingConfigs.release
|
||||
minifyEnabled enableProguardInReleaseBuilds
|
||||
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
||||
}
|
||||
@ -159,6 +161,8 @@ dependencies {
|
||||
|
||||
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
|
||||
|
||||
implementation 'com.github.UnifiedPush:android-connector:2.1.1'
|
||||
|
||||
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
|
||||
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
|
||||
exclude group:'com.squareup.okhttp3', module:'okhttp'
|
||||
|
@ -73,5 +73,19 @@
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
|
||||
<receiver
|
||||
android:enabled="true"
|
||||
android:name=".CustomReceiver"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="org.unifiedpush.android.connector.MESSAGE"/>
|
||||
<action android:name="org.unifiedpush.android.connector.UNREGISTERED"/>
|
||||
<action android:name="org.unifiedpush.android.connector.NEW_ENDPOINT"/>
|
||||
<action android:name="org.unifiedpush.android.connector.REGISTRATION_FAILED"/>
|
||||
<action android:name="org.unifiedpush.android.connector.REGISTRATION_REFUSED"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
|
@ -0,0 +1,31 @@
|
||||
package com.databag;
|
||||
|
||||
import android.content.Context;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.unifiedpush.android.connector.MessagingReceiver;
|
||||
|
||||
public class CustomReceiver extends MessagingReceiver {
|
||||
public CustomReceiver() {
|
||||
super();
|
||||
}
|
||||
@Override
|
||||
public void onNewEndpoint(@NotNull Context context, @NotNull String endpoint, @NotNull String instance) {
|
||||
// Called when a new endpoint be used for sending push messages
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegistrationFailed(@NotNull Context context, @NotNull String instance) {
|
||||
// called when the registration is not possible, eg. no network
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnregistered(@NotNull Context context, @NotNull String instance) {
|
||||
// called when this application is unregistered from receiving push messages
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(@NotNull Context context, @NotNull byte[] message, @NotNull String instance) {
|
||||
// Called when a new message is received. The message contains the full POST body of the push message
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.databag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import com.facebook.react.ReactActivity;
|
||||
@ -7,6 +8,9 @@ import com.facebook.react.ReactActivityDelegate;
|
||||
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
|
||||
import com.facebook.react.defaults.DefaultReactActivityDelegate;
|
||||
|
||||
import org.unifiedpush.android.connector.UnifiedPush;
|
||||
import org.unifiedpush.android.connector.RegistrationDialogContent;
|
||||
|
||||
public class MainActivity extends ReactActivity {
|
||||
|
||||
/**
|
||||
@ -21,6 +25,14 @@ public class MainActivity extends ReactActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(null);
|
||||
|
||||
UnifiedPush.registerAppWithDialog(
|
||||
this,
|
||||
"default",
|
||||
new RegistrationDialogContent(),
|
||||
new ArrayList<String>(),
|
||||
getApplicationContext().getPackageName()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,3 +20,15 @@ buildscript {
|
||||
classpath("com.facebook.react:react-native-gradle-plugin")
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
maven {
|
||||
url "https://www.jitpack.io"
|
||||
content {
|
||||
includeModule 'com.github.UnifiedPush', 'android-connector'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6251,6 +6251,11 @@ react-native-screens@^3.20.0:
|
||||
react-freeze "^1.0.0"
|
||||
warn-once "^0.1.0"
|
||||
|
||||
react-native-share@^8.2.2:
|
||||
version "8.2.2"
|
||||
resolved "https://registry.yarnpkg.com/react-native-share/-/react-native-share-8.2.2.tgz#987d6f164afe57b089950dca42e0555f19045d27"
|
||||
integrity sha512-kVCI/cT0GnuYUTXe6mAimrjrnt4VWoRfrWqJZjFeoYFqAyOEfos84RC4eZlZnOT5eVtmTXRIkor5vgSkKOlZhw==
|
||||
|
||||
react-native-sqlite-storage@^6.0.1:
|
||||
version "6.0.1"
|
||||
resolved "https://registry.npmjs.org/react-native-sqlite-storage/-/react-native-sqlite-storage-6.0.1.tgz"
|
||||
|
Loading…
x
Reference in New Issue
Block a user