Skip to content

Instantly share code, notes, and snippets.

{
"aps":{
"alert":{
"loc-key":"My Localized String",
"loc-args":[
"First argument",
"Second argument"
]
},
"badge":1,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[application setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum];
return YES;
}
-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
// Call or write any code necessary to get new data, process it and update the UI.
// The logic for informing iOS about the fetch results in plain language:
if (/** NEW DATA EXISTS AND WAS SUCCESSFULLY PROCESSED **/) {
completionHandler(UIBackgroundFetchResultNewData);
}
if (/** NO NEW DATA EXISTS **/) {
@brandhill
brandhill / Android Privacy Policy Template
Created February 13, 2017 14:45 — forked from alphamu/Android Privacy Policy Template
A template for creating your own privacy policy for Android apps. Look for "[" and "<!--" to see where you need to edit this app in order to create your own privacy olicy.
<html>
<body>
<h2>Privacy Policy</h2>
<p>[Individual or Company Name] built the [App Name] app as a [open source | free | freemium | ad-supported | commercial] app. This SERVICE is provided by [Individual or company name] [at no cost] and is intended
for use as is.</p>
<p>This page is used to inform website visitors regarding [my|our] policies with the collection, use, and
disclosure of Personal Information if anyone decided to use [my|our] Service.</p>
<p>If you choose to use [my|our] Service, then you agree to the collection and use of information in
relation with this policy. The Personal Information that [I|we] collect are used for providing and
improving the Service. [I|We] will not use or share your information with anyone except as described
@brandhill
brandhill / iosLocalizationPayload.json
Created November 23, 2016 03:09
a sample for push localization payload
{
"aps":{
"alert":{
"loc-key":"My Localized String",
"loc-args":[
"First argument",
"Second argument"
]
},
"badge":1,
@brandhill
brandhill / debug_push.py
Created November 16, 2016 06:56
Test APN push notification certificates (PEM key)
# How do I test my APN push notification certificates (PEM key)?
# https://www.pubnub.com/knowledge-base/discussion/234/how-do-i-test-my-pem-key
# You can test your PEM key using the following command, which should hang if successful until you press enter:
# openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert pnpush.pem -key pnpush.pem
# The above tests the PEM Key in sandbox mode. For production mode, use the following command:
# openssl s_client -connect gateway.push.apple.com:2195 -cert pnpush.pem -key pnpush.pem
# You can also test your PEM Key by running the Python script below using the script below. The usage would be:
# python push_debug.py <CERT_PATH> <DEVICE_TOKEN>
@brandhill
brandhill / EachDirectoryPath.md
Created March 21, 2016 04:15 — forked from granoeste/EachDirectoryPath.md
[Android] How to get the each directory path.

System directories

Method Result
Environment.getDataDirectory() /data
Environment.getDownloadCacheDirectory() /cache
Environment.getRootDirectory() /system

External storage directories

@brandhill
brandhill / SymmetricTreeQueue.java
Created December 6, 2015 16:35 — forked from b27lu/SymmetricTreeQueue.java
iteratively solution of Symmetric Tree at LeetCode
/**
* Definition for binary tree
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
public class Solution {
@brandhill
brandhill / Utils.java
Last active February 1, 2016 10:19
常用的 utility functions
// 判斷 app 是否有安裝
private static boolean isPkgInstalled(Context context, String pkgName) {
PackageInfo packageInfo = null;
try {
packageInfo = context.getPackageManager().getPackageInfo(pkgName, 0);
} catch (PackageManager.NameNotFoundException e) {
packageInfo = null;
e.printStackTrace();
}
@brandhill
brandhill / TimeFormatConverter.java
Last active August 29, 2015 14:16
Time Format Converter
String timeStamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis());
// current UNIX time millsecond to yyyy-MM-dd HH:mm:ss