Sunday 12 July 2015

Apple: Notification Program

1. Register an Apple Developer ID
     149 A$ per year
2. Build the development environment.
    iOS: 8.2
    XCode: 6.4
    Object-C:
3. Develop a server-end program that outputs notifications.
example code:
-------------------------------
public static ArrayList<String> tokens = new ArrayList<String>();
public static File keystore_file;
public static String keystore_password = "hongyu";

public static void init() {
keystore_file = new File("DemoCertificate.p12");
  tokens.add("5af0f958ae7bc0b20ff58789e3605ccec0f24485e119ae4aa939d1f95a6b8798");
}

public static void sendAnAlert(String message) throws CommunicationException, KeystoreException, JSONException {
PushNotificationPayload payload = PushNotificationPayload.complex();
payload.addAlert(message);
payload.addCustomDictionary("key1", "Value 1");
List<PushedNotification> notifications = Push.payload(payload, keystore_file, keystore_password, false, tokens);
printPushedNotifications(notifications);
}

4.That's ALL.

No comments:

Post a Comment