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
class ViewController: UIViewController { | |
@IBOutlet weak var textField: UITextField! | |
@IBAction func BtnGoReactView(_ sender: Any) { | |
let messageFromNative: String = textField.text! | |
let rootView = RNViewManager.sharedInstance.viewForModule( | |
"DemoIntegrateRN", | |
initialProperties: ["message_from_native": messageFromNative]) | |
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
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
val btnGoRNScreen = findViewById<Button>(R.id.btnGoRNScreen) | |
val edt = findViewById<EditText>(R.id.editText) | |
btnGoRNScreen.setOnClickListener { | |
val intent = Intent(this@MainActivity, RNModuleActivity::class.java) | |
intent.putExtra("message_from_native", edt.text) | |
startActivity(intent) |
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
{ | |
"name": "DemoIntegrateRN", | |
"version": "0.0.1", | |
"private": true, | |
"scripts": { | |
"start": "node node_modules/react-native/local-cli/cli.js start", | |
"android": "react-native run-android", | |
"ios": "react-native run-ios", | |
"test": "jest", | |
"lint": "eslint ." |
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
void showNotification(message) async { | |
var androidPlatformChannelSpecifics = new AndroidNotificationDetails( | |
Platform.isAndroid ? 'com.dfa.flutterchatdemo' : 'com.duytq.flutterchatdemo', | |
'Flutter chat demo', | |
'your channel description', | |
playSound: true, | |
enableVibration: true, | |
importance: Importance.Max, | |
priority: Priority.High, | |
); |
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
void configLocalNotification() { | |
var initializationSettingsAndroid = new AndroidInitializationSettings('app_icon'); | |
var initializationSettingsIOS = new IOSInitializationSettings(); | |
var initializationSettings = new InitializationSettings(initializationSettingsAndroid, initializationSettingsIOS); | |
flutterLocalNotificationsPlugin.initialize(initializationSettings); | |
} |
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
void registerNotification() { | |
firebaseMessaging.requestNotificationPermissions(); | |
firebaseMessaging.configure(onMessage: (Map<String, dynamic> message) { | |
print('onMessage: $message'); | |
Platform.isAndroid | |
? showNotification(message['notification']) | |
: showNotification(message['aps']['alert']); | |
return; | |
}, onResume: (Map<String, dynamic> message) { |
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
const functions = require('firebase-functions') | |
const admin = require('firebase-admin') | |
admin.initializeApp() | |
exports.sendNotification = functions.firestore | |
.document('messages/{groupId1}/{groupId2}/{message}') | |
.onCreate((snap, context) => { | |
console.log('----------------start function--------------------') | |
const doc = snap.data() |
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
returnFromDetail = () => { | |
this.isAtCurrentScreen = true | |
this.getListNoteFromDb() | |
} | |
returnFromAddNewNote = () => { | |
this.isAtCurrentScreen = true | |
this.getListNoteFromDb() | |
} |
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
onSaveNotePress = () => { | |
Keyboard.dismiss() | |
if (this.refTextInputTitle && this.refTextInputTitle._lastNativeText && this.refTextInputContent && this.refTextInputContent._lastNativeText) { | |
this.setState({ isLoading: true }) | |
let newNote = { | |
title: this.refTextInputTitle._lastNativeText, | |
updated_at: moment().unix(), | |
content: this.refTextInputContent._lastNativeText, | |
img: this.state.image | |
} |
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
deleteNote = () => { | |
this.setState({isLoading: true}) | |
localNoteDb.remove(this.idNote, this.state.detailNote._rev) | |
.then(response => { | |
if (response.ok) { | |
this.handleBackPress() | |
} else { | |
Toast.show('Delete note fail') | |
this.setState({isLoading: false}) | |
} |