react-native-template-app-basic
v1.0.0
Published
- Instalação e configuração de algumas dependências para estudos sobre realm.io, react-navigation, react-native-vector-icons, socket.io, styled-components e notificações. Eh necessário configurar as Notificações e Push Notificações conforme abaixo
Downloads
3
Readme
Pacote Basico Para Estudos de React Native.
- Instalação e configuração de algumas dependências para estudos sobre realm.io, react-navigation, react-native-vector-icons, socket.io, styled-components e notificações. Eh necessário configurar as Notificações e Push Notificações conforme abaixo
Configurando as Notificações No Ambiente Android.
React Native Push Notifications title
- Altere o arquivo AndroidManifest.xml abaixo das tags uses-permission
<uses-permission android:name="android.permission.INTERNET" /> <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"/>
- Altere o arquivo AndroidManifest.xml ao final da tag application
<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"/> <!-- Change the resource name to your App's accent color - or any other color you want --> <meta-data android:name="com.dieam.reactnativepushnotification.notification_color" android:resource="@android:color/white"/> <!-- < Only if you're using GCM or localNotificationSchedule() > --> <receiver android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="${applicationId}" /> </intent-filter> </receiver> <!-- < Only if you're using GCM or localNotificationSchedule() > --> <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" /> <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/> <!-- < Only if you're using GCM or localNotificationSchedule() > --> <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerServiceGcm" android:exported="false" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> </intent-filter> </service> <!-- </ Only if you're using GCM or localNotificationSchedule() > --> <!-- < Else > --> <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService" android:exported="false" > <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service>
** Crie um arquivo em /android/android/app/src/main/res/values/colors.xml
<resources> <color name="white">#FFF</color> </resources>
** Adicone a Importação abaixo em MainApplication.java
import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage;
Configurando as Notificações No Ambiente IOS.
- @react-native-community/push-notification-ios
Altere o arquivo AppDelegate.m conforme abaixo
- No topo
#import <RNCPushNotificationIOS.h>
- Ao Final
// Required to register for notifications - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { [RNCPushNotificationIOS didRegisterUserNotificationSettings:notificationSettings]; } // Required for the register event. - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; } // Required for the notification event. You must call the completion handler after handling the remote notification. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]; } // Required for the registrationError event. - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error]; } // Required for the localNotification event. - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { [RNCPushNotificationIOS didReceiveLocalNotification:notification]; }
Configurando as Notificações somente no Ambiente IOS.
Altere o arquivo AppDelegate.m conforme abaixo
- No topo
#import "RNNotifications.h"
- Localize o metodo e adicona as linhas conforme abaxio
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [RNNotifications startMonitorNotifications]; // -> Add this line return YES; }
- Localize o metodo e adicona as linhas conforme abaxio
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [RNNotifications didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; // -> Add this line [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; }
- Localize o metodo e adicona as linhas conforme abaxio
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { [RNNotifications didFailToRegisterForRemoteNotificationsWithError:error]; // -> Add this line [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error]; }