Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@evianzhow
Last active March 26, 2018 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evianzhow/87f15ae7066994fd924c251860efb18f to your computer and use it in GitHub Desktop.
Save evianzhow/87f15ae7066994fd924c251860efb18f to your computer and use it in GitHub Desktop.
jpush-react-native with lodash throttle
const registerJPush = (alias, tags) => {
if (!JPushConnected) {
return throttledRegister(alias, tags);
}
if (alias) {
JPushModule.setAlias(alias, ({ errorCode = 0 }) => {
if (errorCode) {
throttledRegister(alias, null);
}
});
} else {
JPushModule.deleteAlias(callback);
}
if (tags) {
JPushModule.setTags(tags, callback);
} else {
JPushModule.cleanTags(callback);
}
};
const throttledRegister = throttle(registerJPush, 20 * 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment