firebase
This commit is contained in:
parent
dfa698542b
commit
63499e8373
@ -1,6 +1,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "FirebaseSDK.h"
|
||||
#import "FirebaseMessaging/FIRMessaging.h"
|
||||
#import "NativeUtils.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -8,7 +9,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*GetFirebaseTokenCallback)(const char* token);
|
||||
@property (nonatomic) GetFirebaseTokenCallback firebaseTokenCallback;
|
||||
GetFirebaseTokenCallback firebaseTokenCallback;
|
||||
|
||||
// 初始化SDK
|
||||
void FIRInitialize() {
|
||||
@ -30,15 +31,15 @@ extern "C" {
|
||||
}
|
||||
|
||||
void FIRGetToken(GetFirebaseTokenCallback callback) {
|
||||
self.firebaseTokenCallback = callback;
|
||||
firebaseTokenCallback = callback;
|
||||
[[FIRMessaging messaging] tokenWithCompletion:^(NSString *token, NSError *error) {
|
||||
if (error != nil) {
|
||||
NSLog(@"Error getting FCM registration token: %@", error);
|
||||
} else {
|
||||
NSLog(@"FCM registration token: %@", token);
|
||||
if (self.firebaseTokenCallback){
|
||||
if (firebaseTokenCallback){
|
||||
const char *pConstToken = [token UTF8String];
|
||||
self.firebaseTokenCallback(pConstToken);
|
||||
firebaseTokenCallback(pConstToken);
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user