|
28 | 28 | i.e., android:name="com.custom.package.MainApplication" |
29 | 29 | */ |
30 | 30 | public class ParsePushApplication extends Application { |
31 | | - public static final String LOGTAG = "ParsePushApplication"; |
| 31 | + public static final String LOGTAG = "ParsePushApplication"; |
32 | 32 |
|
33 | | - @Override |
34 | | - public void onCreate(){ |
35 | | - super.onCreate(); |
| 33 | + @Override |
| 34 | + public void onCreate() { |
| 35 | + super.onCreate(); |
36 | 36 |
|
37 | | - try { |
38 | | - // Other ways to call ParsePushReaderConfig: |
39 | | - // |
40 | | - // - Tell the reader to parse custom parameters, e.g., <preference name="CustomParam1" value="foo" /> |
41 | | - // ParsePushConfigReader config = new ParsePushConfigReader(getApplicationContext(), null, new String[] {"CustomParam1", "CustomParam2"}); |
42 | | - // |
43 | | - // - If you write your own MainApplication in your app package, just import com.yourpackage.R and skip detecting R.xml.config |
44 | | - // ParsePushConfigReader config = new ParsePushConfigReader(getApplicationContext(), R.xml.config, null); |
45 | | - // |
| 37 | + try { |
| 38 | + // Other ways to call ParsePushReaderConfig: |
| 39 | + // |
| 40 | + // - Tell the reader to parse custom parameters, e.g., <preference name="CustomParam1" value="foo" /> |
| 41 | + // ParsePushConfigReader config = new ParsePushConfigReader(getApplicationContext(), null, new String[] {"CustomParam1", "CustomParam2"}); |
| 42 | + // |
| 43 | + // - If you write your own MainApplication in your app package, just import com.yourpackage.R and skip detecting R.xml.config |
| 44 | + // ParsePushConfigReader config = new ParsePushConfigReader(getApplicationContext(), R.xml.config, null); |
| 45 | + // |
46 | 46 |
|
| 47 | + // Simple config reading for opensource parse-server: |
| 48 | + // 1st null to detect R.xml.config resource id, 2nd null indicates no custom config param |
| 49 | + //ParsePushConfigReader config = new ParsePushConfigReader(getApplicationContext(), null, null); |
| 50 | + // |
| 51 | + //Parse.initialize(new Parse.Configuration.Builder(this) |
| 52 | + // .applicationId(config.getAppId()) |
| 53 | + // .server(config.getServerUrl()) // The trailing slash is important, e.g., https://mydomain.com:1337/parse/ |
| 54 | + // .build() |
| 55 | + //); |
47 | 56 |
|
48 | | - // Simple config reading for opensource parse-server: |
49 | | - // 1st null to detect R.xml.config resource id, 2nd null indicates no custom config param |
50 | | - //ParsePushConfigReader config = new ParsePushConfigReader(getApplicationContext(), null, null); |
51 | | - // |
52 | | - //Parse.initialize(new Parse.Configuration.Builder(this) |
53 | | - // .applicationId(config.getAppId()) |
54 | | - // .server(config.getServerUrl()) // The trailing slash is important, e.g., https://mydomain.com:1337/parse/ |
55 | | - // .build() |
56 | | - //); |
57 | | - |
58 | | - // |
59 | | - // Support parse.com and opensource parse-server |
60 | | - // 1st null to detect R.xml.config |
61 | | - ParsePushConfigReader config = new ParsePushConfigReader(getApplicationContext(), null, new String[] {"ParseClientKey"}); |
62 | | - if(config.getServerUrl().equalsIgnoreCase("PARSE_DOT_COM")){ |
63 | | - // |
64 | | - //initialize for use with legacy parse.com |
65 | | - Parse.initialize(this, config.getAppId(), config.getClientKey()); |
66 | | - } else { |
67 | | - Log.d(LOGTAG, "ServerUrl " + config.getServerUrl()); |
68 | | - Log.d(LOGTAG, "NOTE: The trailing slash is important, e.g., https://mydomain.com:1337/parse/"); |
69 | | - Log.d(LOGTAG, "NOTE: Set the clientKey if your server requires it, otherwise it can be null"); |
70 | | - // |
71 | | - // initialize for use with opensource parse-server |
72 | | - Parse.initialize(new Parse.Configuration.Builder(this) |
73 | | - .applicationId(config.getAppId()) |
74 | | - .server(config.getServerUrl()) |
75 | | - .clientKey(config.getClientKey()) |
76 | | - .build() |
77 | | - ); |
78 | | - } |
| 57 | + // |
| 58 | + // Support parse.com and opensource parse-server |
| 59 | + // 1st null to detect R.xml.config |
| 60 | + ParsePushConfigReader config = new ParsePushConfigReader(getApplicationContext(), null, |
| 61 | + new String[] { "ParseClientKey" }); |
| 62 | + if (config.getServerUrl().equalsIgnoreCase("PARSE_DOT_COM")) { |
| 63 | + // |
| 64 | + //initialize for use with legacy parse.com |
| 65 | + Parse.initialize(this, config.getAppId(), config.getClientKey()); |
| 66 | + } else { |
| 67 | + Log.d(LOGTAG, "ServerUrl " + config.getServerUrl()); |
| 68 | + Log.d(LOGTAG, "NOTE: The trailing slash is important, e.g., https://mydomain.com:1337/parse/"); |
| 69 | + Log.d(LOGTAG, "NOTE: Set the clientKey if your server requires it, otherwise it can be null"); |
| 70 | + // |
| 71 | + // initialize for use with opensource parse-server |
| 72 | + Parse.initialize(new Parse.Configuration.Builder(this).applicationId(config.getAppId()) |
| 73 | + .server(config.getServerUrl()).clientKey(config.getClientKey()).build()); |
| 74 | + } |
79 | 75 |
|
80 | | - Log.d(LOGTAG, "Saving Installation in background"); |
81 | | - // |
82 | | - // save installation. Parse.Push will need this to push to the correct device |
83 | | - ParseInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() { |
84 | | - @Override |
85 | | - public void done(ParseException ex) { |
86 | | - if (null != ex) { |
87 | | - Log.e(LOGTAG, ex.toString()); |
88 | | - } else { |
89 | | - Log.d(LOGTAG, "Installation saved"); |
90 | | - } |
91 | | - } |
92 | | - }); |
| 76 | + Log.d(LOGTAG, "Saving Installation in background"); |
| 77 | + // |
| 78 | + // save installation. Parse.Push will need this to push to the correct device |
| 79 | + ParseInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() { |
| 80 | + @Override |
| 81 | + public void done(ParseException ex) { |
| 82 | + if (null != ex) { |
| 83 | + Log.e(LOGTAG, ex.toString()); |
| 84 | + } else { |
| 85 | + Log.d(LOGTAG, "Installation saved"); |
| 86 | + } |
| 87 | + } |
| 88 | + }); |
93 | 89 |
|
94 | | - } catch(ParsePushConfigException ex){ |
95 | | - Log.e(LOGTAG, ex.toString()); |
96 | | - } |
97 | | - } |
| 90 | + } catch (ParsePushConfigException ex) { |
| 91 | + Log.e(LOGTAG, ex.toString()); |
| 92 | + } |
| 93 | + } |
98 | 94 | } |
0 commit comments