enter code here
Я использую от OneSignal в моем проекте.Как я могу установить proxy
, когда я использую с OneSignal
?
Ниже приведен мой код, но я использую его из Интернета без proxy
:
new Thread(new Runnable() {
@Override
public void run() {
try {
String userName = "userNAme";
String pass = "Pass";
Authenticator authenticator = new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return (new PasswordAuthentication(userName, pass.toCharArray()));
}
};
Authenticator.setDefault(authenticator);
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("xx.xxx.xx", 443));
HttpURLConnection connection = (HttpURLConnection) new URL("https://onesignal.com/").openConnection(proxy);
connection.usingProxy();
connection.setAllowUserInteraction(true);
connection.connect();
if (connection.getResponseCode() == 200) {
OneSignal.startInit(App.this)
.inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
.setNotificationReceivedHandler(new NotificationReceivedHandler())
.setNotificationOpenedHandler(new NotificationOpenedHandler(App.this))
.unsubscribeWhenNotificationsAreDisabled(true)
.init();
}
} catch (Exception ex) {
}
}
}).start();