Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
react-native-fcm
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ym
react-native-fcm
Commits
75bd35dd
Commit
75bd35dd
authored
Jul 17, 2017
by
Libin Lu
Committed by
GitHub
Jul 17, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #467 from riyaz942/master
Delete instanceId function
parents
6baaf814
84296f5d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
2 deletions
+38
-2
README.md
README.md
+9
-0
android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java
...rc/main/java/com/evollu/react/fcm/FIRMessagingModule.java
+12
-1
index.js
index.js
+4
-0
ios/RNFIRMessaging.h
ios/RNFIRMessaging.h
+1
-1
ios/RNFIRMessaging.m
ios/RNFIRMessaging.m
+12
-0
No files found.
README.md
View file @
75bd35dd
...
...
@@ -372,6 +372,15 @@ class App extends Component {
my_custom_data_1: 'my_custom_field_value_1',
my_custom_data_2: 'my_custom_field_value_2'
});
FCM.deleteInstanceId()
.then( () => {
//Deleted instance id successfully
//This will reset Instance ID and revokes all tokens.
})
.catch(error => {
//Error while deleting instance id
});
}
}
```
...
...
android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java
View file @
75bd35dd
...
...
@@ -27,7 +27,7 @@ import android.os.Bundle;
import
android.util.Log
;
import
android.content.Context
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Map
;
import
java.util.Set
;
...
...
@@ -74,6 +74,17 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule implements Li
promise
.
resolve
(
FirebaseInstanceId
.
getInstance
().
getToken
());
}
@ReactMethod
public
void
deleteInstanceId
(
Promise
promise
){
try
{
FirebaseInstanceId
.
getInstance
().
deleteInstanceId
();
promise
.
resolve
(
null
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
promise
.
reject
(
null
,
e
.
getMessage
());
}
}
@ReactMethod
public
void
presentLocalNotification
(
ReadableMap
details
)
{
Bundle
bundle
=
Arguments
.
toBundle
(
details
);
...
...
index.js
View file @
75bd35dd
...
...
@@ -48,6 +48,10 @@ FCM.getFCMToken = () => {
return
RNFIRMessaging
.
getFCMToken
();
};
FCM
.
deleteInstanceId
=
()
=>
{
return
RNFIRMessaging
.
deleteInstanceId
();
};
FCM
.
getAPNSToken
=
()
=>
{
if
(
Platform
.
OS
===
'
ios
'
)
{
return
RNFIRMessaging
.
getAPNSToken
();
...
...
ios/RNFIRMessaging.h
View file @
75bd35dd
...
...
@@ -3,7 +3,7 @@
#import <FirebaseCore/FIRApp.h>
#import <FirebaseMessaging/FirebaseMessaging.h>
#import <FirebaseInstanceID/FirebaseInstanceID.h>
#import <React/RCTEventEmitter.h>
@import
UserNotifications
;
...
...
ios/RNFIRMessaging.m
View file @
75bd35dd
...
...
@@ -231,6 +231,18 @@ RCT_EXPORT_METHOD(getFCMToken:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromi
resolve
([
FIRMessaging
messaging
].
FCMToken
);
}
RCT_EXPORT_METHOD
(
deleteInstanceId
:
(
RCTPromiseResolveBlock
)
resolve
rejecter
:
(
RCTPromiseRejectBlock
)
reject
)
{
[[
FIRInstanceID
instanceID
]
deleteIDWithHandler
:
^
(
NSError
*
_Nullable
error
)
{
if
(
error
!=
nil
)
{
reject
([
NSString
stringWithFormat
:
@"%ld"
,
error
.
code
],
error
.
localizedDescription
,
nil
);
}
else
{
resolve
(
nil
);
}
}];
}
-
(
void
)
messaging
:(
nonnull
FIRMessaging
*
)
messaging
didRefreshRegistrationToken
:(
nonnull
NSString
*
)
fcmToken
{
[
self
sendEventWithName
:
FCMTokenRefreshed
body
:
fcmToken
];
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment