Comments (5)
Please give me some code snippets of index.android.js
from react-native-gcm-android.
I'm currently using snippets from the example to just try to get it to work (see below). Note that I've already registered my token with my server (not shown here), and am using this example page as a reduced repro case for myself.
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
DeviceEventEmitter,
} = React;
var GcmAndroid = require('react-native-gcm-android');
import Notification from 'react-native-system-notification';
console.log('index.android.js==============================');
console.log(GcmAndroid.launchNotification);
if (GcmAndroid.launchNotification) {
console.log('GcmAndroid.launchNotification:', GcmAndroid.launchNotification);
var notification = GcmAndroid.launchNotification;
var info = JSON.parse(notification.info);
Notification.create({
subject: info.subject,
message: info.message,
});
GcmAndroid.stopService();
} else {
var GoGoMonkeyBusiness = React.createClass({
componentDidMount: function() {
GcmAndroid.addEventListener('register', function(token){
console.log('send gcm token to server', token);
});
GcmAndroid.addEventListener('notification', function(notification){
console.log('receive gcm notification', notification);
});
DeviceEventEmitter.addListener('sysNotificationClick', function(e) {
console.log('sysNotificationClick', e);
});
GcmAndroid.requestPermissions();
},
render: function() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.android.js
</Text>
<Text style={styles.instructions}>
Shake or press menu button for dev menu
</Text>
</View>
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('GoGoMonkeyBusiness', () => GoGoMonkeyBusiness);
}
from react-native-gcm-android.
Weird.... Can you try the demo project?
from react-native-gcm-android.
So, it's working now, but I am not certain of the culprit.
The demo worked as advertised. Even though last night's version bump wasn't really relevant here, I decided to upgrade this plugin for my project just to get parity with the demo project. Then, after restarting the phone and ensuring that the react native packager was fresh, it just worked. So unfortunately, I don't have a great rationale to contribute here. I'll definitely update here if I find anything, but otherwise, thanks for your quick attention and pointer to try out the demo project!
Log (note the unreferenced classes and notification builder issues are still here, so likely irrelevant):
I/GCM ( 1435): GCM message com.gogomonkey.business 0:1453214615376206%e20063ecf9fd7ecd
D/dalvikvm( 7823): Late-enabling CheckJNI
I/ActivityManager( 1084): Start proc com.gogomonkey.business for broadcast com.gogomonkey.business/com.google.android.gms.gcm.GcmReceiver: pid=7823 uid=10207 gids={50207, 3003, 1028, 1015, 3002}
I/dalvikvm( 7823): Could not find method android.app.Notification$Builder.setLocalOnly, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza
W/dalvikvm( 7823): VFY: unable to resolve virtual method 236: Landroid/app/Notification$Builder;.setLocalOnly (Z)Landroid/app/Notification$Builder;
D/dalvikvm( 7823): VFY: replacing opcode 0x6e at 0x00c8
I/dalvikvm( 7823): Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zzj
W/dalvikvm( 7823): VFY: unable to resolve virtual method 544: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
D/dalvikvm( 7823): VFY: replacing opcode 0x6e at 0x000b
I/GMPM ( 7823): App measurement is starting up
I/dalvikvm( 7823): Could not find method android.app.Notification$Builder.setColor, referenced from method com.google.android.gms.gcm.zza.zzw
W/dalvikvm( 7823): VFY: unable to resolve virtual method 222: Landroid/app/Notification$Builder;.setColor (I)Landroid/app/Notification$Builder;
D/dalvikvm( 7823): VFY: replacing opcode 0x6e at 0x0068
D/RNGcmListenerService( 7823): sendNotification
D/BackgroundService( 7823): onStartCommand
D/Sensors ( 1084): AccelerationSensor: set delay 66
D/dalvikvm( 7823): Trying to load lib /data/app-lib/com.gogomonkey.business-2/libreactnativejni.so 0x41f83938
D/dalvikvm( 7823): Added shared lib /data/app-lib/com.gogomonkey.business-2/libreactnativejni.so 0x41f83938
D/dalvikvm( 7823): Trying to load lib /data/app-lib/com.gogomonkey.business-2/libreactnativejni.so 0x41f83938
D/dalvikvm( 7823): Shared lib '/data/app-lib/com.gogomonkey.business-2/libreactnativejni.so' already loaded in same CL 0x41f83938
I/dalvikvm( 7823): threadid=1: recursive native library load attempt (/data/app-lib/com.gogomonkey.business-2/libreactnativejni.so)
D/dalvikvm( 7823): Trying to load lib /data/app-lib/com.gogomonkey.business-2/libfbjni.so 0x41f83938
D/dalvikvm( 7823): Added shared lib /data/app-lib/com.gogomonkey.business-2/libfbjni.so 0x41f83938
I/dalvikvm( 7823): Could not find method com.facebook.react.views.view.ReactViewGroup.drawableHotspotChanged, referenced from method com.facebook.react.views.view.ReactViewManager.receiveCommand
W/dalvikvm( 7823): VFY: unable to resolve virtual method 24770: Lcom/facebook/react/views/view/ReactViewGroup;.drawableHotspotChanged (FF)V
D/dalvikvm( 7823): VFY: replacing opcode 0x6e at 0x002d
I/dalvikvm( 7823): Could not find method com.facebook.react.views.view.ReactViewGroup.setElevation, referenced from method com.facebook.react.views.view.ReactViewManager.setElevation
W/dalvikvm( 7823): VFY: unable to resolve virtual method 24806: Lcom/facebook/react/views/view/ReactViewGroup;.setElevation (F)V
D/dalvikvm( 7823): VFY: replacing opcode 0x6e at 0x000a
D/WifiStateMachine( 1084): handleMessage: E msg.what=151572
D/WifiStateMachine( 1084): processMsg: ConnectedState
D/WifiStateMachine( 1084): processMsg: L2ConnectedState
D/WifiStateMachine( 1084): handleMessage: X
I/SFPerfTracer( 327): triggers: (rate: 0:0) (29211 sw vsyncs) (0 skipped) (18:16155 vsyncs) (20:46086)
I/dalvikvm( 7823): Could not find method android.webkit.CookieManager.setCookie, referenced from method com.facebook.react.modules.network.ForwardingCookieHandler.addCookieAsync
W/dalvikvm( 7823): VFY: unable to resolve virtual method 16883: Landroid/webkit/CookieManager;.setCookie (Ljava/lang/String;Ljava/lang/String;Landroid/webkit/ValueCallback;)V
D/dalvikvm( 7823): VFY: replacing opcode 0x6e at 0x0005
I/dalvikvm( 7823): Could not find method android.webkit.CookieManager.removeAllCookies, referenced from method com.facebook.react.modules.network.ForwardingCookieHandler.clearCookiesAsync
W/dalvikvm( 7823): VFY: unable to resolve virtual method 16880: Landroid/webkit/CookieManager;.removeAllCookies (Landroid/webkit/ValueCallback;)V
D/dalvikvm( 7823): VFY: replacing opcode 0x6e at 0x0009
I/dalvikvm( 7823): Could not find method android.webkit.CookieManager.flush, referenced from method com.facebook.react.modules.network.ForwardingCookieHandler$CookieSaver.flush
W/dalvikvm( 7823): VFY: unable to resolve virtual method 16876: Landroid/webkit/CookieManager;.flush ()V
D/dalvikvm( 7823): VFY: replacing opcode 0x6e at 0x0006
D/ConnectivityService( 1084): handleInetConditionHoldEnd: net=1, condition=100, published condition=100
I/ModemStatsDSDetect( 1253): onReceive() -Intent { act=android.net.conn.INET_CONDITION_ACTION flg=0x4000010 (has extras) }
I/SBar.NetworkController( 1178): onReceive: ConnectivityManager.INET_CONDITION_ACTION Received
I/SBar.NetworkController( 1178): updateConnectivity: NetworkInfo: NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "SXCTS", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, inetCondition= 1
I/ModemStatsDSDetect( 1253): INET_CONDITION=100 ,activeNet=NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "SXCTS", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false
I/ModemStatsDSDetect( 1253): onReceive() - done, currentInetCondition=100
W/dalvikvm( 7823): VFY: unable to find class referenced in signature (Ljava/nio/file/Path;)
W/dalvikvm( 7823): VFY: unable to find class referenced in signature ([Ljava/nio/file/OpenOption;)
I/dalvikvm( 7823): Could not find method java.nio.file.Files.newOutputStream, referenced from method okio.Okio.sink
W/dalvikvm( 7823): VFY: unable to resolve static method 46635: Ljava/nio/file/Files;.newOutputStream (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/OutputStream;
D/dalvikvm( 7823): VFY: replacing opcode 0x71 at 0x000a
W/dalvikvm( 7823): VFY: unable to find class referenced in signature (Ljava/nio/file/Path;)
W/dalvikvm( 7823): VFY: unable to find class referenced in signature ([Ljava/nio/file/OpenOption;)
I/dalvikvm( 7823): Could not find method java.nio.file.Files.newInputStream, referenced from method okio.Okio.source
W/dalvikvm( 7823): VFY: unable to resolve static method 46634: Ljava/nio/file/Files;.newInputStream (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/InputStream;
D/dalvikvm( 7823): VFY: replacing opcode 0x71 at 0x000a
I/ReactNativeJS( 7823): index.android.js==============================
I/ReactNativeJS( 7823): index.android.js==============================
I/ReactNativeJS( 7823): { message: 'bar',
I/ReactNativeJS( 7823): title: 'foo',
I/ReactNativeJS( 7823): sound: 'true',
I/ReactNativeJS( 7823): collapse_key: 'do_not_collapse' }
I/ReactNativeJS( 7823): 'GcmAndroid.launchNotification:', { message: 'bar',
I/ReactNativeJS( 7823): title: 'foo',
I/ReactNativeJS( 7823): sound: 'true',
I/ReactNativeJS( 7823): collapse_key: 'do_not_collapse' }
I/dalvikvm( 7823): Could not find method android.widget.ImageView.<init>, referenced from method com.facebook.drawee.view.DraweeView.<init>
W/dalvikvm( 7823): VFY: unable to resolve direct method 17156: Landroid/widget/ImageView;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;II)V
D/dalvikvm( 7823): VFY: replacing opcode 0x70 at 0x0000
I/dalvikvm( 7823): Could not find method com.facebook.drawee.view.DraweeView.getImageTintList, referenced from method com.facebook.drawee.view.DraweeView.init
W/dalvikvm( 7823): VFY: unable to resolve virtual method 19393: Lcom/facebook/drawee/view/DraweeView;.getImageTintList ()Landroid/content/res/ColorStateList;
D/dalvikvm( 7823): VFY: replacing opcode 0x6e at 0x0015
I/dalvikvm( 7823): Could not find method android.app.Notification$Builder.setLocalOnly, referenced from method io.neson.react.notification.Notification.build
W/dalvikvm( 7823): VFY: unable to resolve virtual method 236: Landroid/app/Notification$Builder;.setLocalOnly (Z)Landroid/app/Notification$Builder;
D/dalvikvm( 7823): VFY: replacing opcode 0x6e at 0x010a
I/ReactSystemNotification( 7823): Notification Show: 66847
I/ReactSystemNotification( 7823): Notification Created: 66847
from react-native-gcm-android.
Restarting everything may solve the problem sometimes when developing React Native app. 😩
from react-native-gcm-android.
Related Issues (20)
- npm version is newer than github version HOT 1
- App crashes when closed while receiving notification HOT 5
- npm WARN [email protected] requires a peer of react-native-system-notification@^0.1.2 but none was installed. HOT 7
- Error: 'GcmAndroid.launchNotification internal', undefined HOT 1
- Handling AndroidManifest.xml with buildtypes and applicationIdSuffix HOT 1
- com.facebook.react.bridge.UnexpectedNativeTypeException: TypeError: expected dynamic type `int64', but had type `double'
- issue with implementaion HOT 2
- App does not receive messages after reboot on Android 5.0 HOT 1
- App crashes while in background
- Cant get token HOT 1
- RN 0.29 needs Activity instance? HOT 3
- Emitter
- SysNotificationClick as Listener doesn´t work for me (Android)
- Oney: Are you still interested in keeping this library up to date? I can help HOT 1
- Error :app:transformClassesWithJarMeringForDebug HOT 1
- google services
- No static method builder() Lcom/facebook/react/ReactInstanceManager$Builder; HOT 1
- I'm getting this error when I run my app. No error shows up while building though. Please help me
- react-native-fcm
- ar
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-gcm-android.