|
23 | 23 | * Provides a set of utilities for using Parse with Twitter. |
24 | 24 | */ |
25 | 25 | public final class ParseTwitterUtils { |
26 | | - /* package */ static final String AUTH_TYPE = "twitter"; |
| 26 | + private static final String AUTH_TYPE = "twitter"; |
| 27 | + |
| 28 | + private static final String CALLBACK_URL = "twittersdk://"; |
27 | 29 |
|
28 | 30 | private static final Object lock = new Object(); |
29 | 31 | /* package for tests */ static boolean isInitialized; |
@@ -51,20 +53,35 @@ public static Twitter getTwitter() { |
51 | 53 | /** |
52 | 54 | * Initializes Twitter for use with Parse. This method must be invoked prior to calling |
53 | 55 | * {@link #link(ParseUser, Context, SaveCallback)} and {@link #logIn(Context, LogInCallback)}. |
54 | | - * |
| 56 | + * |
55 | 57 | * @param consumerKey |
56 | 58 | * Your Twitter consumer key. |
57 | 59 | * @param consumerSecret |
58 | 60 | * Your Twitter consumer secret. |
59 | 61 | */ |
60 | 62 | public static void initialize(String consumerKey, String consumerSecret) { |
| 63 | + initialize(consumerKey, consumerSecret, CALLBACK_URL); |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * Initializes Twitter for use with Parse. This method must be invoked prior to calling |
| 68 | + * {@link #link(ParseUser, Context, SaveCallback)} and {@link #logIn(Context, LogInCallback)}. |
| 69 | + * |
| 70 | + * @param consumerKey |
| 71 | + * Your Twitter consumer key. |
| 72 | + * @param consumerSecret |
| 73 | + * Your Twitter consumer secret. |
| 74 | + * @param callbackUrl |
| 75 | + * the callback url |
| 76 | + */ |
| 77 | + public static void initialize(String consumerKey, String consumerSecret, String callbackUrl) { |
61 | 78 | synchronized (lock) { |
62 | 79 | if (isInitialized) { |
63 | 80 | return; |
64 | 81 | } |
65 | 82 |
|
66 | 83 | if (controller == null) { |
67 | | - Twitter twitter = new Twitter(consumerKey, consumerSecret); |
| 84 | + Twitter twitter = new Twitter(consumerKey, consumerSecret, callbackUrl); |
68 | 85 | controller = new TwitterController(twitter); |
69 | 86 | } else { |
70 | 87 | controller.initialize(consumerKey, consumerSecret); |
@@ -133,7 +150,7 @@ public static void link(ParseUser user, Context context) { |
133 | 150 | * Links a ParseUser to a Twitter account, allowing you to use Twitter for authentication, and |
134 | 151 | * providing access to Twitter data for the user. A dialog will be shown to the user for Twitter |
135 | 152 | * authentication. |
136 | | - * |
| 153 | + * |
137 | 154 | * @param user |
138 | 155 | * The user to link to a Twitter account. |
139 | 156 | * @param context |
@@ -190,7 +207,7 @@ public static void link(ParseUser user, String twitterId, String screenName, Str |
190 | 207 | * Links a ParseUser to a Twitter account, allowing you to use Twitter for authentication, and |
191 | 208 | * providing access to Twitter data for the user. This method allows you to handle getting the |
192 | 209 | * auth tokens for your users, rather than delegating to the provided dialog log-in. |
193 | | - * |
| 210 | + * |
194 | 211 | * @param user |
195 | 212 | * The user to link to a Twitter account. |
196 | 213 | * @param twitterId |
@@ -247,7 +264,7 @@ public static Task<ParseUser> logInInBackground(String twitterId, String screenN |
247 | 264 | * credentials does not already exist, a new user will be created. This method allows you to |
248 | 265 | * handle getting the auth tokens for your users, rather than delegating to the provided dialog |
249 | 266 | * log-in. |
250 | | - * |
| 267 | + * |
251 | 268 | * @param twitterId |
252 | 269 | * The user's Twitter ID. |
253 | 270 | * @param screenName |
@@ -293,7 +310,7 @@ public Task<ParseUser> then(Task<Map<String, String>> task) throws Exception { |
293 | 310 | * Logs in a ParseUser using Twitter for authentication. If a user for the given Twitter |
294 | 311 | * credentials does not already exist, a new user will be created. A dialog will be shown to the |
295 | 312 | * user for Twitter authentication. |
296 | | - * |
| 313 | + * |
297 | 314 | * @param context |
298 | 315 | * An Android context from which the login dialog can be launched. |
299 | 316 | * @param callback |
|
0 commit comments