Commit 1c6d1e04 authored by Rebecca Hughes's avatar Rebecca Hughes

Merge pull request #8 from donald-jackson/master

Add user defined deviceName field
parents e6407db3 175e723f
...@@ -132,6 +132,7 @@ RCT_EXPORT_MODULE() ...@@ -132,6 +132,7 @@ RCT_EXPORT_MODULE()
@"systemVersion": currentDevice.systemVersion, @"systemVersion": currentDevice.systemVersion,
@"model": self.deviceName, @"model": self.deviceName,
@"deviceId": self.deviceId, @"deviceId": self.deviceId,
@"deviceName": currentDevice.name,
@"uniqueId": uniqueId, @"uniqueId": uniqueId,
@"bundleId": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"], @"bundleId": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"],
@"appVersion": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], @"appVersion": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"],
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.learnium.RNDeviceInfo"> package="com.learnium.RNDeviceInfo">
<uses-permission android:name="android.permission.BLUETOOTH"/>
</manifest> </manifest>
...@@ -49,6 +49,16 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -49,6 +49,16 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
e.printStackTrace(); e.printStackTrace();
} }
String deviceName = "Unknown";
try {
BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
deviceName = myDevice.getName();
} catch(Exception e) {
e.printStackTrace();
}
constants.put("deviceName", deviceName);
constants.put("systemName", "Android"); constants.put("systemName", "Android");
constants.put("systemVersion", Build.VERSION.RELEASE); constants.put("systemVersion", Build.VERSION.RELEASE);
constants.put("model", Build.MODEL); constants.put("model", Build.MODEL);
......
...@@ -34,5 +34,8 @@ module.exports = { ...@@ -34,5 +34,8 @@ module.exports = {
}, },
getReadableVersion: function() { getReadableVersion: function() {
return RNDeviceInfo.appVersion + "." + RNDeviceInfo.buildNumber; return RNDeviceInfo.appVersion + "." + RNDeviceInfo.buildNumber;
},
getDeviceName: function() {
return RNDeviceInfo.deviceName;
} }
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment