Report your AdMob earnings via Only One Single XMLHttpRequest

Send XMLHttpRequest

function reqListener () {
  console.log(this.responseText);
}
function admobReport() {
var url = 'https://content.googleapis.com/adsense/v1.4/accounts/';
var accountId = 'pub-xxx'; // change to your own accountId
url += accountId;  
url += '/reports?dimension=APP_ID';
url += '&filter=AD_CLIENT_ID==ca-app-' + accountId;
url += '&metric=EARNINGS'
url += '&startDate=2018-02-01';  // change start date
url += '&endDate=2018-02-24'; // change end date
var oReq = new XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", url);
var AuthorizationToken = 'xxx';  // The way to get it is in this post
oReq.setRequestHeader('Authorization', 'AuthorizationToken');
oReq.send();
}
admobReport();

Response

{
 "kind": "adsense#report",
 "totalMatchedRows": "1",
 "headers": [
  {
   "name": "APP_ID",
   "type": "DIMENSION"
  },
  {
   "name": "EARNINGS",
   "type": "METRIC_CURRENCY",
   "currency": "USD"
  }
 ],
 "rows": [
  [
   "2:com.westminstershortercatechismqa",
   "0.89"
  ]
 ],
 "totals": [
  "",
  "0.89"
 ],
 "averages": [
  "",
  "0.89"
 ],
 "startDate": "2018-02-01",
 "endDate": "2018-02-24"
}
 
We can get the total earnings are 0.89$.

accountId

Just login into your AdSense home page, you will found it.
accountId

AuthorizationToken

Generate Authorization Header at first.
You have to login your AdSense account and grant authorization access.
auth
Press F12 to open developer tool in your browser.
Press "EXECUTE" button again.
Then you will find the Authorization Header.
AuthToken
Remember this Header value and keep it secrect.
Replace the value to the JS code at the begining.
Then you can get your AdMob earnings via just one HTTP get API in any place.

Refers

AdSense Management API
AdMob Reporting
AdSense Management API Get Started

Privacy Policy

Your privacy is critically important to us. At errong.win, we do not collect and transmit any user data.

react-native : multi language support set up, use device locale, react-native-i18n use example

Multi language prepare

.\app\i18n\locales\en.js
export default {
  wcsqa: 'Westminster Shorter Catechism Q&A'
};
.\app\i18n\locales\zh.js
export default {
  wcsqa: '威斯敏斯德小要理问答'
};
.\app\i18n\i18n.js
import I18n from 'react-native-i18n';
import en from './locales/en';
import zh from './locales/zh';

I18n.fallbacks = true;

I18n.translations = {
  en,
  zh
};

export default I18n;

Usage

App.js
import ReactNativeLanguages from 'react-native-languages';
import I18n from './app/i18n/i18n'

ReactNativeLanguages.addEventListener('change', ({ language }) => {
  I18n.locale = language;
});

render() {
    return (
      <View style={styles.container}>
        <View style={styles.header}>
          <Text style={styles.title}>
            {I18n.t('wcsqa')}
          </Text>
          ... // other contents
        </View>
        ... // other contents
      </View>
    )
}

No Image, No Truth

multi-language

Refers

https://github.com/react-community/react-native-languages
https://github.com/AlexanderZaytsev/react-native-i18n
https://errong.win/language-code-for-chinese-should-be-start-with-zh/

react-native : header bar(title + option button) example

Render

   render() {
      return (
        <View style={styles.container}>
          <View style={styles.header}>
            <Text style={styles.title}>
              {I18n.t('wcsqa')} // your title
            </Text>
            <TouchableOpacity onPress={() => {}}>
              <Image
                style={styles.option}
                source={require('./res/img/nav_icon.png')}
              />
            </TouchableOpacity>
          </View>
          <View style={styles.content}>
            <Text>
              {this.wcs[0].Q} // your content
            </Text>
          </View>
        </View>
      )
  }

Style

const styles = StyleSheet.create({
  container: {
    flex: 2,
  },
  header: {
    backgroundColor: '#00FF7F',
    flex: 1,
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'space-around',
  },
  title: {
    fontSize: 20,
    fontWeight: 'bold'
  },
  option: {
    width:32,
    height:32
  },
  content: {
    backgroundColor: '#F5DEB3',
    flex: 12
  }
});

No Image, No Truth

header-bar

language code for Chinese should be start with 'zh'

According to RFC4646 (http://www.ietf.org/rfc/rfc4646.txt)
language codes for Traditional Chinese should be zh-Hant
react-native-i18n
import { getLanguages } from 'react-native-i18n'
getLanguages().then(languages => {
  console.log(languages);
});

Set system language to Chinese

01-24 17:47:47.957 19851 19873 I ReactNativeJS: [ 'zh-Hans-CN', 'en-US' ]

Set system language to English

01-24 17:56:30.754 20563 20584 I ReactNativeJS: [ 'en-US', 'zh-Hans-CN' ]

fixed: embedded-redis: Unable to run on macOS Sonoma

Issue you might see below error while trying to run embedded-redis for your testing on your macOS after you upgrade to Sonoma. java.la...