Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support linking brownfield iOS apps #177

Merged
merged 7 commits into from
Dec 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions BrownfieldTestApp/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["react-native"]
}
6 changes: 6 additions & 0 deletions BrownfieldTestApp/.buckconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[android]
target = Google Inc.:Google APIs:23

[maven_repositories]
central = https://repo1.maven.org/maven2
48 changes: 48 additions & 0 deletions BrownfieldTestApp/.flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[ignore]
; We fork some components by platform
.*/*[.]android.js

; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*

; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js

; Ignore polyfills
.*/Libraries/polyfills/.*

[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow/

[options]
emoji=true

module.system=haste

munge_underscores=true

module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState
suppress_type=$FixMe

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(5[0-6]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(5[0-6]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

unsafe.enable_getters_and_setters=true

[version]
^0.56.0
1 change: 1 addition & 0 deletions BrownfieldTestApp/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pbxproj -text
60 changes: 60 additions & 0 deletions BrownfieldTestApp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml

# node.js
#
node_modules/
npm-debug.log

# BUCK
buck-out/
\.buckd/
android/app/libs
*.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots

# Source maps and debug files
/index.ios.map
/unused.jsbundle*
/.vscode/.react

package-lock.json
1 change: 1 addition & 0 deletions BrownfieldTestApp/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
82 changes: 82 additions & 0 deletions BrownfieldTestApp/AnalyticsScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/

import React from 'react';
import {
Text,
View,
ScrollView,
TouchableOpacity
} from 'react-native';

import Analytics from 'appcenter-analytics';
import SharedStyles from './SharedStyles';

export default class AnalyticsScreen extends React.Component {
constructor() {
super();
this.state = {
analyticsEnabled: false
};
this.toggleEnabled = this.toggleEnabled.bind(this);
}

async componentDidMount() {
const component = this;

const analyticsEnabled = await Analytics.isEnabled();
component.setState({ analyticsEnabled });
}

async toggleEnabled() {
await Analytics.setEnabled(!this.state.analyticsEnabled);

const analyticsEnabled = await Analytics.isEnabled();
this.setState({ analyticsEnabled });
}

/* eslint-disable no-undef */
render() {
return (
<View style={SharedStyles.container}>
<ScrollView >
<Text style={SharedStyles.heading}>
Test Analytics
</Text>

<Text style={SharedStyles.enabledText}>
Analytics enabled: {this.state.analyticsEnabled ? 'yes' : 'no'}
</Text>
<TouchableOpacity onPress={this.toggleEnabled}>
<Text style={SharedStyles.toggleEnabled}>
toggle
</Text>
</TouchableOpacity>

<TouchableOpacity onPress={() => Analytics.trackEvent('Button press', { page: 'Home page' })}>
<Text style={SharedStyles.button}>
Track Event
</Text>
</TouchableOpacity>

<TouchableOpacity onPress={() => Analytics.trackEvent('Button press', { propertyValueTooLong: '12345678901234567890123456789012345678901234567890123456789012345' })}>
<Text style={SharedStyles.button}>
Track Event - event property value truncated after 64 characters
</Text>
</TouchableOpacity>

<TouchableOpacity onPress={() => Analytics.trackEvent('Button press', data)}>
<Text style={SharedStyles.button}>
Track Event badly (Do not do this, only strings are supported)
</Text>
</TouchableOpacity>

</ScrollView>
</View>
);
}
/* eslint-enable no-undef */
}
123 changes: 123 additions & 0 deletions BrownfieldTestApp/CrashesScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/

import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
ScrollView,
TouchableOpacity
} from 'react-native';

import Crashes from 'appcenter-crashes';
import { FooClass } from './js/FooClass';
import SharedStyles from './SharedStyles';

export default class CrashesScreen extends Component {
constructor() {
super();
this.state = {
crashesEnabled: false,
lastSessionStatus: '',
sendStatus: ''
};
this.toggleEnabled = this.toggleEnabled.bind(this);
this.jsCrash = this.jsCrash.bind(this);
this.nativeCrash = this.nativeCrash.bind(this);
}

async componentDidMount() {
let status = '';
const component = this;

const crashesEnabled = await Crashes.isEnabled();
component.setState({ crashesEnabled });

const crashedInLastSession = await Crashes.hasCrashedInLastSession();

status += `Crashed: ${crashedInLastSession ? 'yes' : 'no'}\n\n`;
component.setState({ lastSessionStatus: status });

if (crashedInLastSession) {
const crashReport = await Crashes.lastSessionCrashReport();

status += JSON.stringify(crashReport, null, 4);
component.setState({ lastSessionStatus: status });
}
}

async toggleEnabled() {
await Crashes.setEnabled(!this.state.crashesEnabled);

const crashesEnabled = await Crashes.isEnabled();
this.setState({ crashesEnabled });
}

jsCrash() {
const foo = new FooClass();
foo.method1();
}

nativeCrash() {
Crashes.generateTestCrash();
}

render() {
return (
<View style={SharedStyles.container}>
<ScrollView>
<Text style={SharedStyles.heading}>
Test Crashes
</Text>

<Text style={SharedStyles.enabledText}>
Crashes enabled: {this.state.crashesEnabled ? 'yes' : 'no'}
</Text>
<TouchableOpacity onPress={this.toggleEnabled}>
<Text style={SharedStyles.toggleEnabled}>
toggle
</Text>
</TouchableOpacity>

<TouchableOpacity onPress={this.jsCrash}>
<Text style={styles.button}>
Crash JavaScript
</Text>
</TouchableOpacity>
<TouchableOpacity onPress={this.nativeCrash}>
<Text style={styles.button}>
Crash native code
</Text>
</TouchableOpacity>
<Text style={styles.lastSessionHeader}>Last session:</Text>
<Text style={styles.lastSessionInfo}>
{this.state.lastSessionStatus}
</Text>
</ScrollView>
</View>
);
}
}


const styles = StyleSheet.create({
button: {
color: '#4444FF',
fontSize: 18,
textAlign: 'center',
margin: 10,
},
lastSessionHeader: {
fontSize: 20,
textAlign: 'center',
marginTop: 30
},
lastSessionInfo: {
fontSize: 14,
textAlign: 'center',
},
});
Loading